View Single Post
Old 05-03-2005, 12:26 PM   #18 (permalink)
BUFFY
Registered User
 
Join Date: May 2005
Posts: 29
BUFFY is on a distinguished road
Wow, ok. Thanks DJ, thats really useful. I can understand what your saying.

I can see what you mean by entering in the variables through the URL and setting them that way, it would be quiet simple.

I added the following code before the SELECT query:
PHP Code:
 $username mysql_real_escape_string($username); 
I also added $admin = 1; in tutor, and $admin = 2; in student, which I think should help me in the future for displaying restricted data if $admin == 1; for a tutor.

Now ive basically copied and changed a number of registration examples, some are too advanced for what I need, but this one was quite simple, but when I press the Register button the form just clears the input boxes...

On my register.php page i see it as accepting the input, sending it to itself and doing the sumbit actions. But Im obviously not doing something as it just reloads the page, this time with the input fields blank, no confirmation message, no updated database. I know the password place is wrong as I haven't linked up the include file to validate the registration fields, just wanting to get it updating the database first.

On this page is the following form:

register.php

PHP Code:
<?PHP
if($submit)
{

//Firsty connect to database
include 'connect.inc.php';

$sql "INSERT INTO student
           (title, firstname, lastname, username, password, address, suburb, city, phonenumber, dob) 
           VALUES ('$title', '$firstname', '$lastname', '$username', '$password', '$address', '$suburb', '$city', '$phonenumber', '$dob')"
;
$result mysql_query($sql);
echo 
"Thank you! Information entered.\n";
}
else


?>
<form action="register.php" method="post">
<table width="95%" border="1">
 <tr>
  <td align="left" valign="top">
<table>
 <tr> 
  <td colspan="4"><img src="spacer.gif">Registration Details</td>
 </tr>
 <tr> 
  <td><img src="spacer.gif"></td>
  <td><p>Title:<br>
 (Mr, Miss, Mrs, Dr)&nbsp;</p></td>
   <td colspan="2">
            <select name=title>
            <option >Mr.</option>
            <option >Mrs.</option>
            <option >Ms.</option>
            <option >Dr.</option>
            </select> 
   </td>
  </tr>
  <tr> 
   <td><img src="spacer.gif"></td>
   <td>First Name:&nbsp;</td>
   <td colspan="2"><input type="text" name="firstname"/> 
  </td>
  </tr>
  <tr> 
   <td><img src="spacer.gif"></td>
   <td>Last Name &nbsp;</td>
   <td colspan="2"><input type="text" name="lastname"/> 
   </td>
  </tr>
   <tr> 
  <td><img src="spacer.gif"></td>
  <tdclass="textblue">Email Address:&nbsp;</td>
  <tdclass="text2"><input name="username" type="text" id="username"/> </td>
   <td width="50%"><span class="textred">*vaild email address is required for login username</span></td>
  </tr>
  <tr> 
   <td><img src="spacer.gif"></td>
   <td>Password:&nbsp;</td>
   <td><input name="password1" type="password" id="password1"/></td>
   <td><span class="textred">*up to 20 characters long</span></td>
  </tr>
  <tr> 
   <td><img src="spacer.gif"></td>
   <td>Confirm Password:&nbsp;</td>
   <td colspan="2"><input name="password2" type="password" id="password2"/></td>
  </tr>
  <tr> 
   <td><img src="spacer.gif"></td>
   <td>Address:&nbsp;</td>
   <td colspan="2"><input type="text" name="address"/></td>
  </tr>
  <tr> 
   <td><img src="spacer.gif"></td>
   <td>Suburb:&nbsp;</td>
   <td colspan="2"><input type="text" name="suburb"/> 
   </td>
  </tr>
  <tr> 
   <td><img src="spacer.gif"></td>
   <td>City:&nbsp;</td>
   <td colspan="2"><input type="text" name="city"/> </td>
  </tr>
  <tr> 
   <td><img src="spacer.gif"></td>
   <td>Phone Number: &nbsp;</td>
   <td colspan="2"><input type="text" name="phonenumber"/> 
  </td>
  </tr>
  <tr> 
   <td><img src="spacer.gif"></td>
   <td>Date of Birth:<br>(YEAR-MM-DD format) &nbsp;</td>
   <td colspan="2"><input type="date" name="dob"/> </td>
  </tr><tr align="left" valign="middle">
   <td height="40" colspan="4"><div align="left"> &nbsp; 
   <input name="submit" type="submit"  value="Register"/>
   <input type=reset  name=reset  value="Clear">
 <br>
 </div></td>
  </tr>
 </table>
 <div align="left"></div></td>
 </tr>
</table>
  </form>
<?PHP
}
exit;
?>

Last edited by BUFFY; 05-03-2005 at 01:05 PM.
BUFFY is offline   Reply With Quote