Jump to content

Data not retrieved from form...


Cagecrawler

Recommended Posts

I have written my own script for registering on my website, but when somebody registers, their details aren't stored in my database properly.  I've worked out that the data isn't being retrieved from the form, but I have no idea why.  $date is still being inserted into the database, so this confirms the fact that its a problem with the form.  Below is my code:
[u]The Register Form[/u]
[code]<form action="regprocess.php" method="post">
<table>
<tr>
<td colspan="2"><center>REGISTER</center></td>
<tr>
<tr>
<td>Username:</td>
<td><input type="text" name='post_user'></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name='post_pass'></td>
</tr>
<tr>
<td>Repeat Password:</td>
<td><input type="password" name='repeat_pass'></td>
</tr>
<tr>
<td>Email Address:</td>
<td><input type="text" name='post_email'></td>
</tr>
<tr>
<td><input type="submit" value="Submit" name="Submit"><input type="reset" value="Reset" name="Reset"></td>
<td></td>
</tr>
</table>
</form>[/code]

The PHP Code
[code]<?php

//Get form data + date
$username = $_POST['post_user'];
$password = $_POST['post_pass'];
$repeatpass=$_POST['repeat_pass'];
$email=$_POST['post_email'];
$date = date('j-n-y');

//Check all fields have been filled
if(empty($username)|| empty($password) || empty($repeatpass) || empty($email))
{
//Kill script.  Go fill in all the fields...
die("All fields need to be filled.  Please go back and try again");
}
else
{
if($password == $repeatpass)
{
//Connect to DB
include('include/connect.php');

//Insert data
mysql_query("INSERT INTO users(id,username,password,email,date) VALUES ('','$username','$password','$email','$date')") or die(mysql_error());

//Take to login page
echo("Thank you for registering.  You may now login <a href=\"login.php\">here</a>.");
}
else
{
echo("Passwords do not match.  Please go <a href=\"register.php\">back </a>and try again.");
}
}
?>
[/code]

Thanks in advance...
Link to comment
Share on other sites

Try debugging the variables...

[code]
<?php

<?php

//Get form data + date
$username = $_POST['post_user'];
$password = $_POST['post_pass'];
$repeatpass=$_POST['repeat_pass'];
$email=$_POST['post_email'];
$date = date('j-n-y');

echo $username;
echo $password;
echo $repeatpass;
echo $email;

exit(); //This exits the script so you can see the output...
?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.