mikebyrne Posted November 28, 2007 Share Posted November 28, 2007 I'm trying to combine my start & signup page into the one file but It keeps causeing Apachi to crash. Is there a way to do this?? <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Sign UP</title> </head> <body> <td><form name="form1" method="post" action="signup_ac.php"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Name:</td> <td><input type="text" name="name" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Address:</td> <td><input type="text" name="address" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Address1:</td> <td><input type="text" name="address1" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Address2:</td> <td><input type="text" name="address2" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Address3:</td> <td><input type="text" name="address3" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Address4:</td> <td><input type="text" name="address4" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">County:</td> <td><input type="text" name="county" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Zip:</td> <td><input type="text" name="zip" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Telephone:</td> <td><input type="text" name="telephone" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Email:</td> <td><input type="text" name="email" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Username:</td> <td><input type="text" name="username" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Password:</td> <td><input type="password" name="password" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Insert record"></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1"> </form> <p> </p> </body> </html> <?php include('config.php'); // table name $tbl_name=temp_users; // Random confirmation code $confirm_code=md5(uniqid(rand())); // values sent from form $name=$_POST['name']; $address=$_POST['address']; $address1=$_POST['address1']; $address2=$_POST['address2']; $address3=$_POST['address3']; $address4=$_POST['address4']; $county=$_POST['county']; $zip=$_POST['zip']; $telephone=$_POST['telephone']; $email=$_POST['email']; $username=$_POST['username']; $password=$_POST['password']; // Insert data into database $sql="INSERT INTO $tbl_name(confirm_code, name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password)VALUES('$confirm_code', '$name', '$address', '$address1', '$address2','$address3', '$address4','$county' ,'$zip', '$telephone', '$email', '$username', '$password')"; $result=mysql_query($sql)or die(mysql_error()); // if suceesfully inserted data into database, send confirmation link to email if($result){ // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email; // Your subject $subject="Your confirmation link here"; // From $header="from: postmaster@localhost <postmaster@localhost>"; // Your message $message="Your Comfirmation link \r\n"; $message.="Click on this link to activate your account \r\n"; $message.="http://localhost/confirm.php?passkey=$confirm_code"; // send email $sentmail = mail($to,$subject,$message,$header); } // if not found else { echo "Not found your email in our database"; } // if your email succesfully sent if($sentmail){ echo "Your Confirmation link Has Been Sent To Your Email Address."; } else { echo "Cannot send Confirmation link to your e-mail address"; } ?> Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted November 28, 2007 Author Share Posted November 28, 2007 The code im trying to combine is above on the one page. Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted November 28, 2007 Author Share Posted November 28, 2007 Everytime I open it up my Apachi server crashes. Is that something to do with the code or size of the file?? Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted November 28, 2007 Share Posted November 28, 2007 Is the form action directed to the same page or a different page? And what do you mean apache crashes? Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted November 28, 2007 Author Share Posted November 28, 2007 The form was originaly pointed towards singup_ac.php but now its now pointing to anything (I think) When I run it my localhost seems to crashes Quote Link to comment Share on other sites More sharing options...
Wolphie Posted November 28, 2007 Share Posted November 28, 2007 If i understand you correctly are you trying to make it so that only one page is used? If so this is how i would do it: switch($_GET['do']) { default: echo ' <form action="?do=register" method="post"> Username: <input type="text" name="username" /><br /> Password: <input type="password" name="password" /><br /> <input type="submit" value="Register" /> </form> '; break; case 'register': $username = mysql_escape_string(htmlspecialchars($_POST['username'])); $password = mysql_escape_string(htmlspecialchars(MD5($_POST['password']))); $sql = mysql_query(sprintf("INSERT INTO `users` ( `username`, `password` ) VALUES ( '%s', '%s' )", $username, $password)) or die('Error: ' . mysql_error()); if($sql) { echo 'Registered successfully'; } else { echo 'Failed'; } break; } Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted November 28, 2007 Author Share Posted November 28, 2007 How can i apply that to my code, I'm very new to php Quote Link to comment Share on other sites More sharing options...
revraz Posted November 28, 2007 Share Posted November 28, 2007 So the top HTML is one page, and the signup_ac.php is another page, but is the PHP part of the code you posted? And all works fine as two seperate files? Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted November 29, 2007 Author Share Posted November 29, 2007 So the top HTML is one page, and the signup_ac.php is another page, but is the PHP part of the code you posted? And all works fine as two seperate files? Yes the HTML is from one page where the info was passed to the 2nd page signup_ac.php. All was working fine as two seperate pages. I was just wondering if I could combine them onto one page? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 29, 2007 Share Posted November 29, 2007 If all worked well, then all you should have to do is change the Form Action to itself, and put some PHP code at the top to see if the page has been submitted. <?php if(!isset($_POST['submit'])) { ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Sign UP</title> </head> <body> <td><form name="form1" method="post" action=<?php $_SERVER['PHP_SELF']; ?>> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Name:</td> <td><input type="text" name="name" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Address:</td> <td><input type="text" name="address" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Address1:</td> <td><input type="text" name="address1" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Address2:</td> <td><input type="text" name="address2" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Address3:</td> <td><input type="text" name="address3" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Address4:</td> <td><input type="text" name="address4" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">County:</td> <td><input type="text" name="county" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Zip:</td> <td><input type="text" name="zip" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Telephone:</td> <td><input type="text" name="telephone" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Email:</td> <td><input type="text" name="email" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Username:</td> <td><input type="text" name="username" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Password:</td> <td><input type="password" name="password" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Insert record"></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1"> </form> <p> </p> </body> </html> <?php } else { include('config.php'); // table name $tbl_name=temp_users; // Random confirmation code $confirm_code=md5(uniqid(rand())); // values sent from form $name=$_POST['name']; $address=$_POST['address']; $address1=$_POST['address1']; $address2=$_POST['address2']; $address3=$_POST['address3']; $address4=$_POST['address4']; $county=$_POST['county']; $zip=$_POST['zip']; $telephone=$_POST['telephone']; $email=$_POST['email']; $username=$_POST['username']; $password=$_POST['password']; // Insert data into database $sql="INSERT INTO $tbl_name(confirm_code, name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password)VALUES('$confirm_code', '$name', '$address', '$address1', '$address2','$address3', '$address4','$county' ,'$zip', '$telephone', '$email', '$username', '$password')"; $result=mysql_query($sql)or die(mysql_error()); // if suceesfully inserted data into database, send confirmation link to email if($result){ // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email; // Your subject $subject="Your confirmation link here"; // From $header="from: postmaster@localhost <postmaster@localhost>"; // Your message $message="Your Comfirmation link \r\n"; $message.="Click on this link to activate your account \r\n"; $message.="http://localhost/confirm.php?passkey=$confirm_code"; // send email $sentmail = mail($to,$subject,$message,$header); } // if not found else { echo "Not found your email in our database"; } // if your email succesfully sent if($sentmail){ echo "Your Confirmation link Has Been Sent To Your Email Address."; } else { echo "Cannot send Confirmation link to your e-mail address"; } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.