Jump to content


This topic is now archived and is closed to further replies.


Post to validation form

Recommended Posts

Hi guys,

I have been following the tutorial for the user login system on PHPFreaks but I have a problem with posting the data from the regsitration form to the validation page, all I get is the form reloading itself when I hit the submit button...

I have tried the following:

<form name=form1 method=post action=register.php>
<form name=form1 method=post action="register.php">
<form name=form1 method=post action=/home/fhlinux245/h/blahdeblah.com/user/htdocs/register.php>

I am sure that this should be oh so simple, and yet I am stuck....

Any help would be appreciated.



Share this post

Link to post
Share on other sites
Can you post the full code of both the form and the "register.php" file?


Share this post

Link to post
Share on other sites
I'm having a few problems with the register.php file, but then wouldn't I at least get an error when it tried to post rather than just returning back to the registration page?

Everything below the post is just html for the fields, there is no other php below there.



Share this post

Link to post
Share on other sites
Ok, the join form is like so:

# starting the session here

if ($_SESSION['email_address'] != "youremail@here.com" ) {
echo "<b>Welcome.</b><br><br><br>";

# this prevents a user from typing or pasting a URL string
# into their browser to get to this page. If the $first_name
# variable is empty, then they log in like everyone else.
if ( empty( $first_name ) ) {
print "Please Register Below";


<form id=\"form1\" name=\"userform\" method=\"post\" action="/home/fhlinux245/h/blahdeblah.com/user/htdocs/register.php">
<label>First Name</label>
<input name="first_name" type="text" id="first_name" maxlength="25" />
<form id="form2" name="form2" method="post" action="">
<label>Maiden Name
<input name="maiden_name" type="text" id="maiden_name" value="" />
<form id="form3" name="form3" method="post" action="">
<label>Married Name
<input name="last_name" type="text" id="last_name" />
<form id="form4" name="form4" method="post" action="">
<label>Address Line 1
<input name="address_line1" type="text" id="address_line1" maxlength="255" />
<form id="address_line2" name="address_line2" method="post" action="">
<label>Address Line 2
<input name="address_line2" type="text" id="address_line2" />
<form id="form5" name="form5" method="post" action="">
<input name="town" type="text" id="town" />
<form id="form6" name="form6" method="post" action="">
<select name="select">
<option>Central Scotland</option>
<option>County Antrim</option>
<option>County Down</option>
<option>County Durham</option>
<option>County Fermanagh</option>
<option>County Londonderry</option>
<option>County Tyrone</option>
<option>Dumfries and Galloway</option>
<option>East Ayrshire</option>
<option>East Lothian</option>
<option>East Sussex</option>
<option>East Yorkshire</option>
<option>Greater London</option>
<option>Greater Manchester</option>
<option>Highlands and Islands</option>
<option>Isle of Arran</option>
<option>Isle of Man</option>
<option>Isle of Skye</option>
<option>Isle of Wight</option>
<option>Outer Hebrides</option>
<option>South Yorkshire</option>
<option>Tyne and Wear</option>
<option>West Lothian</option>
<option>West Midlands</option>
<option>West Sussex</option>
<option>West Yorkshire</option>
<option>Wester Ross</option>
<form id="form7" name="form7" method="post" action="">
<input name="postcode" type="text" id="postcode" maxlength="255" />
<form id="form8" name="form8" method="post" action="">
<label>Daytime Phone Number
<input name="daytime_phone" type="text" id="daytime_phone" maxlength="25" />
<form id="form9" name="form9" method="post" action="">
<label>Evening Phone Number
<input name="evening_phone" type="text" id="evening_phone" maxlength="25" />
<form id="form10" name="form10" method="post" action="">
<label>Email Address
<input name="email_address" type="text" id="email_address" maxlength="255" />
<form id="form11" name="form11" method="post" action="">
<label>Date of Birth
<input name="date_ofbirth" type="text" id="date_ofbirth" />
<form id="form12" name="form12" method="post" action="">
<label>Date of Wedding
<input name="wedding_date" type="text" id="wedding_date" maxlength="25" />
<form id="form13" name="form13" method="post" action="">
<label>Wedding Venue
<input name="wedding_venue" type="text" id="wedding_venue" maxlength="255" />
<form id="form14" name="form14" method="post" action="">
<label>Number of Guests
<input name="number_ofguests" type="text" id="number_ofguests" maxlength="255" />
<form id="form15" name="form15" method="post" action="">
<input name="username" type="text" id="username" />
<form id="form16" name="form16" method="post" action="">
<input name="password" type="password" id="password" maxlength="255" />
<form id="form17" name="form17" method="post" action="">
<input type="submit" name="Submit" value="Submit" />
<!-- InstanceEndEditable -->
<!-- InstanceEnd -->

Share this post

Link to post
Share on other sites
Ok, if your still with me, here is the register page it is trying to post to, this has quite afew errors in it which I am getting through slowly...

<?php include ("/home/fhlinux2145/h/blahdeblah.com/user/Includes/db.php");

# grab the POST variables from the HTML form,
# put them into PHP variables so we can work with them
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$maiden_name = $_POST['maiden_name'];
$address_line1 = $_POST['address_line1'];
$address_line2 = $_POST['address_line2'];
$town = $_POST['town'];
$county = $_POST['county'];
$postcode = $_POST['postcode'];
$daytime_phone = $_POST['daytime_phone'];
$evening_phone = $_POST['evening_phone'];
$email_address = $_POST['email_address'];
$date_ofbirth = $_POST['date_ofbirth'];
$wedding_date = $_POST['wedding_date'];
$number_ofguests = $_POST['number_ofguests'];
$wedding_venue = $_POST['wedding_venue'];
$wedding_area = $_POST['wedding_area'];
$username = $_POST['username'];
$info = $_POST['info'];

# Any escaped characters? No, not a jailbreak...something that could
# cause errors when PHP processes. We check for that here.
$first_name = stripslashes($first_name);
$maiden_name = stripslashes($maiden_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$info = stripslashes($info);

# Any errors in the posted fields? Lets check...
# If there is an error, then we show the join form again
# so they can fill it out again. If everything
# checks out, then go ahead with your bad self!
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
echo 'You did not submit the following required information! <br />';
echo "First Name is a required field. Please enter it below.<br />";
echo "Maiden Name is a required field. Please enter it below.<br />";
echo "Email Address is a required field. Please enter it below.<br />";
echo "Desired Username is a required field. Please enter it below.<br />";
// }
// include 'join_form.html';
// exit();

# does this user already exist in the database? lets check for that now...
$sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'");
$sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");

$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);

if(($email_check > 0) || ($username_check > 0)){
echo "Please fix the following errors: <br />";
if($email_check > 0){
echo "<strong>Your email address has already been used by another member in our database. Please use a different Email address!<br />";
if($username_check > 0){
echo "The username you have selected has already been used by another member in our database. Please choose a different Username!<br />";
include 'join_form.php'; // Show the form again!

# everything checks out so far, so lets add this user!

/* Random Password generator. Thanks a ton, phpfreak!
[a href=\"http://www.phpfreaks.com/quickcode/Random_Password_Generator/56.php\" target=\"_blank\"]http://www.phpfreaks.com/quickcode/Random_...enerator/56.php[/a]
We'll generate a random password for the
user and encrypt it, email it and then enter it into the db.

function makeRandomPassword() {
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
$i = 0;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
return $pass;

$random_password = makeRandomPassword();

$db_password = md5($random_password);

/* Enter info into the Database.
I changed a little bit here from phpfreak's awesome tutorial on this subject. When I would get data from the user, I would not get an unencrypted password, only the md5 encrypted one. I couldn't use that, and me being the powertrip guy, I wrote in another little snippet to grab that password before it gets encrypted and stuff it into a blank variable, and write it to the database. Pretty nifty, eh?
$info2 = htmlspecialchars($info);
$sql = mysql_query("INSERT INTO users (first_name, maiden_name, last_name, address_line1, address_line2, town, county, postcode, daytime_phone, evening_phone, email_address, date_ofbirth, wedding_date, number_ofguests, wedding_venue, wedding_area, email_address, username, password, info, signup_date,

VALUES('$first_name', '$maiden_name', '$email_address', '$username', '$db_password', '$info2', now(), '$random_password')") or die (mysql_error());

echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
$userid = mysql_insert_id();
// Let's mail the user!
$subject = "Your account has been created!";
$message = "Dear $first_name $last_name,
You are now registered at our website, [a href=\"http://www.blahdeblah.com\" target=\"_blank\"]http://www.blahdeblah.com[/a]!

To activate your membership, please login here: [a href=\"http://www.blahdeblah.com/Registration/customerlogin/login_form.html\" target=\"_blank\"]http://www.blahdeblah.com/Registration/cus...login_form.html[/a]

Once you activate your membership, you will be able to login with the following information:
Username: $username
Password: $random_password
Please keep this username and password in a location that is easily accessible by you.


This is an automated response, please do not reply!";

mail($email_address, $subject, $message, "From: <webmaster@blahdeblah.com>\nX-Mailer: PHP/" . phpversion());
echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';
} }

Share this post

Link to post
Share on other sites


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.