Jump to content


Photo

Post to validation form


  • Please log in to reply
5 replies to this topic

#1 genista

genista
  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts

Posted 25 April 2006 - 12:33 PM

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.

Thanks,

G

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 25 April 2006 - 01:25 PM

Can you post the full code of both the form and the "register.php" file?

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 genista

genista
  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts

Posted 25 April 2006 - 02:52 PM

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.

Thanks,

G

#4 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 25 April 2006 - 03:03 PM

post the code.
wisewood: proven fact, I am both wise, and wooden.

#5 genista

genista
  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts

Posted 25 April 2006 - 03:16 PM

Ok, the join form is like so:

<?php
# 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";

}
}
?>


<html>
<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>
<label></label>
<form id="form2" name="form2" method="post" action="">
<label>Maiden Name
<input name="maiden_name" type="text" id="maiden_name" value="" />
</label>
</form>
<form id="form3" name="form3" method="post" action="">
<label>Married Name
<input name="last_name" type="text" id="last_name" />
</label>
</form>
<form id="form4" name="form4" method="post" action="">
<label>Address Line 1
<input name="address_line1" type="text" id="address_line1" maxlength="255" />
</label>
</form>
<form id="address_line2" name="address_line2" method="post" action="">
<label>Address Line 2
<input name="address_line2" type="text" id="address_line2" />
</label>
</form>
<form id="form5" name="form5" method="post" action="">
<label>Town
<input name="town" type="text" id="town" />
</label>
</form>
<form id="form6" name="form6" method="post" action="">
<label>County
<select name="select">
<option>Aberdeenshire</option>
<option>Anglesey</option>
<option>Angus</option>
<option>Argyll</option>
<option>Avon</option>
<option>Ayrshire</option>
<option>Banffshire</option>
<option>Bedfordshire</option>
<option>Berkshire</option>
<option>Berwickshire</option>
<option>Borders</option>
<option>Buckinghamshire</option>
<option>Bute</option>
<option>Caithness</option>
<option>Cambridgeshire</option>
<option>Central Scotland</option>
<option>Cheshire</option>
<option>Clackmananshire</option>
<option>Cleveland</option>
<option>Clwyd</option>
<option>Cornwall</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>Cumbria</option>
<option>Denbighshire</option>
<option>Derbyshire</option>
<option>Devon</option>
<option>Dorset</option>
<option>Dumfries and Galloway</option>
<option>Dunbartonshire</option>
<option>Durham</option>
<option>Dyfed</option>
<option>East Ayrshire</option>
<option>East Lothian</option>
<option>East Sussex</option>
<option>East Yorkshire</option>
<option>Edinburgh</option>
<option>Essex</option>
<option>Fife</option>
<option>Glamorgan</option>
<option>Gloucestershire</option>
<option>Grampian</option>
<option>Greater London</option>
<option>Greater Manchester</option>
<option>Guernsey</option>
<option>Gwent</option>
<option>Gwynedd</option>
<option>Hampshire</option>
<option>Herefordshire</option>
<option>Hertfordshire</option>
<option>Highlands and Islands</option>
<option>Humberside</option>
<option>Inverness-shire</option>
<option>Isle of Arran</option>
<option>Isle of Man</option>
<option>Isle of Skye</option>
<option>Isle of Wight</option>
<option>Jersey</option>
<option>Kent</option>
<option>Lanarkshire</option>
<option>Lancashire</option>
<option>Leicestershire</option>
<option>Lincolnshire</option>
<option>Lochaber</option>
<option>London</option>
<option>Londonderry</option>
<option>Lothian</option>
<option>Merseyside</option>
<option>Middlesex</option>
<option>Moray</option>
<option>Nottinghamshire</option>
<option>Orkneys</option>
<option>Outer Hebrides</option>
<option>Oxfordshire</option>
<option>Peeblesshire</option>
<option>Perthshire</option>
<option>Powys</option>
<option>Shropshire</option>
<option>Somerset</option>
<option>South Yorkshire</option>
<option>Staffordshire</option>
<option>Stirlingshire</option>
<option>Strathclyde</option>
<option>Suffolk</option>
<option>Surrey</option>
<option>Sussex</option>
<option>Sutherland</option>
<option>Swansea</option>
<option>Tayside</option>
<option>Tyne and Wear</option>
<option>Warwickshire</option>
<option>West Lothian</option>
<option>West Midlands</option>
<option>West Sussex</option>
<option>West Yorkshire</option>
<option>Wester Ross</option>
<option>Wiltshire</option>
<option>Worcestershire</option>
</select>
</label>
</form>
<form id="form7" name="form7" method="post" action="">
<label>Postcode
<input name="postcode" type="text" id="postcode" maxlength="255" />
</label>
</form>
<form id="form8" name="form8" method="post" action="">
<label>Daytime Phone Number
<input name="daytime_phone" type="text" id="daytime_phone" maxlength="25" />
</label>
</form>
<form id="form9" name="form9" method="post" action="">
<label>Evening Phone Number
<input name="evening_phone" type="text" id="evening_phone" maxlength="25" />
</label>
</form>
<form id="form10" name="form10" method="post" action="">
<label>Email Address
<input name="email_address" type="text" id="email_address" maxlength="255" />
</label>
</form>
<form id="form11" name="form11" method="post" action="">
<label>Date of Birth
<input name="date_ofbirth" type="text" id="date_ofbirth" />
</label>
</form>
<form id="form12" name="form12" method="post" action="">
<label>Date of Wedding
<input name="wedding_date" type="text" id="wedding_date" maxlength="25" />
</label>
</form>
<form id="form13" name="form13" method="post" action="">
<label>Wedding Venue
<input name="wedding_venue" type="text" id="wedding_venue" maxlength="255" />
</label>
</form>
<form id="form14" name="form14" method="post" action="">
<label>Number of Guests
<input name="number_ofguests" type="text" id="number_ofguests" maxlength="255" />
</label>
</form>
<p>&nbsp;</p>
<form id="form15" name="form15" method="post" action="">
<label>Username
<input name="username" type="text" id="username" />
</label>
</form>
<form id="form16" name="form16" method="post" action="">
<label>Password
<input name="password" type="password" id="password" maxlength="255" />
</label>
</form>
<form id="form17" name="form17" method="post" action="">
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</form>
<p>&nbsp;</p>
</html>
<!-- InstanceEndEditable -->
<p>&nbsp;</p>
</body>
<!-- InstanceEnd -->

#6 genista

genista
  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts

Posted 25 April 2006 - 03:27 PM

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 />';
if(!$first_name){
echo "First Name is a required field. Please enter it below.<br />";
}
if(!$lmaiden_name){
echo "Maiden Name is a required field. Please enter it below.<br />";
}
if(!$email_address){
echo "Email Address is a required field. Please enter it below.<br />";
}
if(!$username){
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 />";
unset($email_address);
}
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 />";
unset($username);
}
include 'join_form.php'; // Show the form again!
exit();
}

# 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";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
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,

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

if(!$sql){
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.

Thanks!
WebMaster,

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!';
} }
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users