Web designing newb. Creating a PHP forum from scratch!

I've now done a large amount on the member database.

How would I read from the session so the user can only see the topic and detail, but once the user has posted it would be like:

Name: <Insert username from session>
Topic:
Detail:

Would it be something along the lines of?:

Code:
session_start();
$username=$_GET['username'];
$_SESSION['username']=$username;

Something I fail to understand, how would it pass information back and forth between pages? Would I have to insert something in all my php files?
 
Last edited:
I've now come to a halt. Complete failure. Everything has crashed burnt and died.

Everything was going really well, I managed to register users, log in and allowed threaded responses. I decided to add sessions and remove the name field so that when a user posts it uses sessions to recall their username and allow the user to post that. It's gone all downhill from there.

When a user successfully logged in, it redirected them to a successful login page. The page just contained:

Code:
<?php
session_start();
$_SESSION['myusername']=$myusername;
<html>
<body>
Login Successful
</body><br />
<a href=main_forum.php>Return to Main forum</a>
</html>

And on top of the relevant pages it's had the rest of the code:

Code:
<?php
session_start();
$myusername = $_SESSION['myusername'];

Now I had 3 tables; Making threads, replies and members.

The name fields I had were name, a_name and myusername.

I've just made a complete mess and confused the hell out of me. as I renamed them to myusername, a_myusername and myusername.

All I want it to do is just display the user name.

I'd appreciate any help :(

Edit: I also forgot to add, I also get this error:

Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0
 
Last edited:
I know what you're trying to achieve there, and I've attempted to use the same base for the forum. I also ran into a problem when getting the forum to automatically use the username, so I used a 'GET' function - this was not the most appropriate option, as the URL could be manipulated. What I'm saying is, maybe you could try to use a unique login number through a SQL session. You could use the 'GET' function to get the ID in the URL, for example: http://myurl.com/viewposts.php?id=randomcodehere and then use the SQL to use the random code to a user name. Perhaps that could be a temporary fix.
 
set $_SESSION['myusername'] on your login page if it was successful. that way you can assign it to whatever the form value was..... and then re-direct to the index page or whatever.

your 2nd bit for the top of each other page is fine.
 
Have just spent over 8 hours and I've been focusing design and it's worked out fairly well. However, I've found a bug I can't seem to sort out.

When a user who hasn't registered tries to create a topic they get a message asking their to either login or register. However, when an unregistered user tries to post a reply they also get the same error but the message somehow still posts without a user :confused:

Code:
if ($myusername == ""){
echo "In order to post you must login or register<BR>";
echo "<a href=login.php>Click here to login<BR></a>";
echo "<a href=register.php>Click here to register<BR></a>";}
elseif ($result2){
echo "Successful<BR>";
echo "<a href='view_thread.php?id=".$id."'>View your reply</a>";

// If added new reply, add value +1 in reply column
$tbl_name2="create_thread";
$sql3="UPDATE $tbl_name2 SET reply='$Max_id' WHERE id='$id'";
$result3=mysql_query($sql3);
}
else {
echo "ERROR: The SQL Server said:<br />" . mysql_error();
}
 
at the top of each page that requires you to be logged in, i'd just have a re-direct straight to the login page....

Code:
<?php
session_start();
if(!$_SESSION['myusername']) {
    header("Location: login.php");
    exit;
}
$myusername = $_SESSION['myusername'];
//carry on.....
 
I've redesigned how I want it to look for 2 reasons: i) It looks far better ii) Should be easier to implement.

This is the part I'm struggling with a lot.

72606632zf4.jpg


The tables are just a bit tarded when it comes to formatting them. For example, I added a border and this is how it looks:

gbordermq5.jpg


I'd appreciate any help on how I can start to make it look like that. For an experienced user it's a matter of minutes knowing where to start. With me it's a lost cause and hours :\
 
Thank you James :)

CSS is pretty damn good!

35462198mw4.jpg


I can't seem to figure out to create a new instance of a table header. The first table is spot on. However, the second navigation bar, I want it like my design. I've tried creating a class/instance but its not working.

For example I have:

Code:
table
{
background-color: #000000;
border: 2px solid #f39707;
width: 70%;
border-collapse: collapse;
}

Could I say create a table2? How do I create individual styles of each table?
 
use classes. (note the . that precedes the name in the css.) eg

Code:
.table1 {
}

.table2 {
}

then in your html, use

Code:
<table class="table1">
</table>

<table class="table2">
</table>
 
Thanks once again marc :)

Regarding background images, I have the following defined:

Code:
body
{
background: #000000 url(images/bg.jpg);
background-attachment: fixed;
background-repeat: no-repeat;
background-position: top right;
}

Yet the image appears in the centre of the page.

Edit: I've also been reading up on aligning stuff, how would I align all my tables on every page the way I want it? Can I just explicitly state where I can my tables? Also, is there a method where I can use percentage like I've done with most of tables, to state for example how much percent of a person web browser I want the table to be positioned instead of stating an absolute value or similar?

Edit 2: Solved the image problem, used xpos and ypos :)
 
Last edited:
loginlj2.jpg


How can I add a small space in between the password and the login button?

Code:
<td><input class="smallfont" size="10%" name="mypassword" type="password" id="mypassword">
<input class="button" type="submit" name="Submit" value="Login"></td>

And finally, how can shorten the distance between the login form and the orange navigation bar? I have <br> tags and when I remove one it all goes dodgy :confused:
 
&nbsp; should add a space between the password box and the login box.

Code:
<td><input class="smallfont" size="10%" name="mypassword" type="password" id="mypassword">
&nbsp;<input class="button" type="submit" name="Submit" value="Login"></td>

Or add another column to the table that holds the login info.
 
Back
Top Bottom