Adding PHP to an HTML form?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bedcor
Forum Newbie
Posts: 24
Joined: Fri Jul 26, 2002 11:01 am
Location: Barrie, Ontario

Adding PHP to an HTML form?

Post by bedcor »

I have been working on getting sessions to show up on each page. I have a html form and at the top of the page i want to display the session for the users name, and i'm not sure where to put the session information?

this is the form:
[syntax=php]<html>
<head>
<title>Client Information</title>
</head>
<body text="#ffcc66" bgcolor="black">
<form method="post" action="ClientData.php">
<font size=+3><b><center>Client Information</center></b></font>
<center>
<table border="3">
<tr>
<td><strong><b>Contact Name:</b></strong></td>
<td><input type=text maxlength=70 name=contact_name size=40></td>
</tr>
<tr>
<br>
<td><strong><b>Position:</b></strong></td>
<td><input type=text maxlength=70 name=position size=40></td>
</tr>
<tr>
<br>
<td><strong><b>Department:</b></strong></td>
<td><input type=text maxlength=70 name=department size=40></td>
</tr>
<tr>
<br>
<td><strong><b>Street Name:</b></strong></td>
<td><input type=text maxlength=70 name=street size=40></td>
</tr>
<tr>
<br>
<td><strong><b>City:</b></strong></td>
<td><input type=text maxlength=70 name=city size=40></td>
</tr>
<tr>
<br>
<td><strong><b>Province/State:</b></strong></td>
<td><input type=text maxlength=70 name=prov_state size=40></td>
</tr>
<tr>
<br>
<td><strong><b>Country:</b></strong></td>
<td><input type=text maxlength=70 name=country size=40></td>
</tr>
<tr>
<br>
<td><strong><b>Postal/Zip:</b></strong></td>
<td><input type=text maxlength=70 name=zip_postal size=40></td>
</tr>
<tr>
<br>
<td><strong><b>Phone Number:</b></strong></td>
<td><input type=text maxlength=70 name=phNumber size=40></td>
</tr>
<tr>
<br>
<td><strong><b>Fax Number:</b></strong></td>
<td><input type=text maxlength=70 name=faxNumber size=40>
</tr>
<tr>
<br>
<td><strong><b>Pager Number:</b></strong></td>
<td><input type=text maxlength=70 name=pagerNumber size=40>
</tr>
<tr>
<br>
<td><strong><b>Email Address:</b></strong></td>
<td><input type=text maxlength=70 name=email size=40>
</tr>
</table>
<br>
<input type=reset style=color:yellow; style=background:black; style=border:grey; style=font-size:14; style=font-weight:bold; value="Reset Form"> <input type=submit style=color:yellow; style=background:black; style=border:grey; style=font-size:14; style=font-weight:bold; value="Save" name="button"> <input type=submit style=color:yellow; style=background:black; style=border:grey; style=font-size:14; style=font-weight:bold; value="Update Client" name="button"> <input type=submit style=color:yellow; style=background:black; style=border:grey; style=font-size:14; style=font-weight:bold; value="Delete" name="button">
<br>
<br>
<a href="ClientView.php" style=color:#ff6600; style=background:black; style=border:black; style=font-size:16;><b>Click Here To See List Of Registered Users!</b></a>
</form>
</center>
</body>
</html>[/syntax]

this is the session :
[syntax=php]<?
session_start();
echo "Welcome <b>{$_SESSION['username']}</b> to Client Information!";
?>[/syntax]

Thanks
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

you have to register variables...

http://www.php.net/session_register ...
or, as supposedly it is better to do, declare them, like
$_SESSION['foo'] = "bar";

so like,

Code: Select all

<?
session_start();

// either

// $foo = $_POST&#1111;'foo'];
// session_register('foo');

// or

// $_SESSION&#1111;'foo'] = $_POST&#1111;'foo'];

?>
Post Reply