barbs75 Posted February 19, 2008 Share Posted February 19, 2008 Hey guys, This might be a really simple question, i'm still quite new to php at the moment, so things are still a bit confusing... Im doing a registration system for my website, and i have a register form, which used to echo a message when registration was complete saying "thankyou for registering". I didnt want this anymore, and decided instead to have a screen from my website come up with menu and bottom footer etc with a message. the navigation of this is made more clear below: 1. Register.html - html form where user inputs data and is submitted to register_process.php 2. Register_process.php - process the entered data in form which validates the entries and puts the data into mysql database, and has an include script to include register_success.html (used to just have an echo script saying that registration was successful) 3. Register_success.html - has html code with CSS to output a registration complete screen What is the standard procedure for this? do i need to use an include script to bring up the register_success.html page after the user has registered? or do i simply put the html script in register_process.php??? In my code at the moment i have used an include script to include register_success.html if the registration is done with no errors, but at the moment when i test it, a white page appears with nothing in it.... Just want to know the proper way of doing this, i want my website to be as professional as possible my url to the website is as follows: www.go4home.co.uk The code for the three pages i have mentioned above are below register.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="Style1.css" /> <title>Go4home.co.uk - Find your dream property, or advertise your house for sale on the property market on go4home.co.uk</title> <meta name="Description" content="Find your dream property online, Search for any property for sale in a range of areas in the UK with go4home" /> <meta name="Keywords" content="Find a property, find property, find property in UK, search for a property, Property up for sale, find property up for sale, Property market, Advertise your home to sell, go4home.co.uk, go4home" /> </head> <body> <div id="mainContainer"> <div id="container-Content"> <div id="content-TopContent"> <div id="TopBar"> <div id="Logo"><img src="Images/Go4Home-logo.jpg" alt="Go4home.co.uk" width="201" height="39" /></div> <div id="myProfile"></div> <div id="Login"><a href="login_form.html">login</a></div> <div id="NotRegisteredText"><a class="blue" href="register.html">Not Registered?</a></div> </div><!--End of TopBar --> <ul id="navigationMenu"> <li class="HomeButton"><a href="index.html"></a></li> <li class="SearchButton"><a href="Construction Page.html"></a></li> <li class="MoneyMarketButton"><a href="Construction Page.html"></a></li> <li class="GoBuyButton"><a href="Construction Page.html"></a></li> <li class="GoSellButton"><a href="Construction Page.html"></a></li> <li class="HelpButton"><a href="Construction Page.html"></a></li> </ul> </div><!--End of content-Topcontent --> <div id="content-centrecontent"> <br /> <h2 class="shadow">Register</h2> <br /> <p class="centreContent">Already Registered with us? If you are already a member of go4home.co.uk, then please<br> sign in. if not, then please fill in our easy-to-fill form below to join!</p> <p class="centreContent">After registering, we will send you an email, to confirm your details</p> <div id="submitCustomerForm"> <FORM ACTION="register_process.php" METHOD="POST" NAME="contact_form"> <TABLE width="572"> <TR> <TD height="35" colspan="2"><h3>Your Details</h3></TD> <TD></TD> <TD></TD> </TR> <TR> <TD colspan="3"><span class="asterix">*</span> Indicates a required field</TD> <TD></TD> </TR> <TR> <TD></TD> <TD width="187">Your Username:<span class="asterix"> *</span><br /><span class="textSmallGreen">(letters and numbers only)</span></TD> <TD width="27"></TD> <TD width="318"> <input class="fade" name="username" type=text size="50" maxlength="50"></TD> </TR> <TR> <TD></TD> <TD>Your Title:</TD> <TD></TD> <TD><label> <select class="fade" name="titleList" id="titleList"> <option class="fade">--Please Select--</option> <option class="fade" value="Mr">Mr</option> <option class="fade" value="Miss">Miss</option> <option class="fade" value="Mrs">Mrs</option> <option class="fade" value="Ms">Ms</option> </select> </label></TD> </TR> <TR> <TD></TD> <TD>Your Surname: <span class="asterix">*</span></font></TD> <TD></TD> <TD> <input class="fade" name="surname" type=text size="50" maxlength="15"></TD> </TR> <TR> <TD></TD> <TD>Your Forename: <span class="asterix">*</span></TD> <TD></TD> <TD> <input class="fade" name="forename" type=text size="50" maxlength="15"></TD> </TR> <TR> <TD></TD> <TD>Email Address: <span class="asterix">*</span></font></TD> <TD></TD> <TD><input class="fade" name="email" type=text size="50" maxlength="30"></TD> </TR> <TR> <TD></TD> <TD>Your Password: <span class="asterix">*</span></font></TD> <TD></TD> <TD> <input class="fade" name="password" type=password size="50" maxlength="15"></TD> </TR> <TR> <TD></TD> <TD>Confirm Password: <span class="asterix">*</span><br /><span class="textSmallGreen">(Please re enter password)</span></TD> <TD></TD> <TD> <input class="fade" name="password2" type=password size="50" maxlength="15"></TD> </TR> <TR> <TD></TD> <TD>Your Membership: <span class="asterix">*</span></font></TD> <TD></TD> <TD><input class="fade" name="membership" type=text size="50" maxlength="6"></TD> </TR> <TR> <TD height="27" colspan="4"><span class="divider"><hr /></span></TD> </TR> <TR> <TD colspan="2"><h3>Privacy Settings</h3></TD> <TD></TD> <TD></TD> </TR> <TR> <TD width="20" height="22" align="left"><label> <input name="consent1" type="checkbox" id="Consent1" checked="checked" /> </label></TD> <TD colspan="3" align="left">I will allow further contact in the future from go4home only</TD> </TR> <TR> <TD width="20" height="22" align="right"></TD> <TD colspan="3" align="left"><span class="textSmall">This will include emails on latest promotions and services, our newsletters and other important information. You are ensured of no contact from third party</span></TD> </TR> <TR> <TD height="22" align="left"><label> <input type="checkbox" name="consent2" id="Consent2" /> </label></TD> <TD colspan="3" align="left">I allow for future contact from third party</TD> </TR> <TR> <TD height="22" align="right"></TD> <TD colspan="3" align="left"><span class="textSmall">go4home may share my details with third party organizations who may have relevant products that might be of some interest</span></TD> </TR> <TR> <TD height="22" colspan="4" align="left"><span class="divider"><hr /></span></TD> </TR> <TR> <TD height="22" colspan="4" align="left"><h3>Terms & Conditions</h3></TD> </TR> <TR> <TD height="22" colspan="4" align="left"><label></label> <span class="textSmall">For protection of all our go4home customers, we recommend you take a look at our terms & Conditions</span></TD> </TR> <TR> <TD height="22" align="right"><label> <input type="checkbox" name="termsCond" id="Terms&Conditions" /> </label></TD> <TD colspan="3" align="left">I have read and agree to the go4home terms & Conditions</TD> </TR> <TR> <TD height="22" colspan="4" align="left"><span class="divider"><hr /></span></TD> </TR> <TR> <TD height="45" align="right"></TD> <TD align="left"></TD> <TD align="right"></TD> <TD align="right"><input name="Submit" type="image" src="Images/submitButton.png" /></TD> </TR> </TABLE> </FORM> </div><!--End of submitCustomerForm--> </div><!--End of content-centreContent--> </div><!--End of container-Content--> <div id="footer"> <ul id="footerMenu"> <li><a href="Construction Page.html">Go4home terms & conditions</a></li> <li><a href="Construction Page.html">Accessibility</a></li> <li><a href="Construction Page.html">About Us</a></li> <li><a href="Construction Page.html">Privacy Policy</a></li> <li><a href="Construction Page.html">Contact Us</a></li> </ul> <div id="CopyrightText"></div> </div><!--End of footer --> </div><!--End of mainContainer--> </body> </html> register_process.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Registration Process</title> </head> <body> <?php $con = mysql_connect("localhost","root","12waldron"); //Replace with your actual MySQL DB Username and Password if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("customerhouses_db", $con); //Replace with your MySQL DB Name $username=$_POST['username']; $encryptusername=md5($_POST['username']); $title=$_POST['titleList']; $surname=$_POST['surname']; $forename=$_POST['forename']; //This value has to be the same as in the HTML form file $email=$_POST['email']; //This value has to be the same as in the HTML form file $encryptpass=md5($_POST['password']); $encryptpass2=md5($_POST['password2']); $password = $_POST['password']; $membership=$_POST['membership']; $consent1=$_POST['consent1']; $consent2=$_POST['consent2']; $termsConditions=$_POST['termsCond']; //checking for existing users in database $checkuser = mysql_query("SELECT username FROM customer WHERE username='$username'"); $username_exist = mysql_num_rows($checkuser); if($username_exist > 0){ unset($username); echo "I'm sorry but the username you specified has already been taken. Please pick another one."; exit(); } //checking if passwords match if ($encryptpass != $encryptpass2) { echo "Im sorry, your passwords do not match, please re enter and try again"; exit(); } //checking username isn't over a certain character length $username = trim($username); if(strlen($username) > 12){ die("Sorry, the username is longer than 12 characters, please shorten it."); } //checking for entry in all fields of form if(!$username || !$surname || !$forename || !$email || !$encryptpass || !$encryptpass2 || !$membership){ die('You didn\'t fill in a required field.'); } //checking for acceptance of terms and conditions if(!isset($termsConditions)){ die('Please read and accept our terms and conditions by ticking the appropriate box, thankyou'); } $sql="INSERT INTO customer (username,encryptusername,title,surname,forename,email,encryptpass,password,membership,consent1,consent2) VALUES ('$username','$encryptusername','$title','$surname','$forename','$email','$encryptpass','$password','$membership', '$consent1', '$consent2')"; /*form_data is the name of the MySQL table where the form data will be saved. name and email are the respective table fields*/ //echo $password; //echo $encryptpass; //echo $encryptpass2; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } include("register_success.php"); mysql_close($con); //email user confirmation of registration $yoursite = 'www.go4home.co.uk'; $webmaster = 'The go4home development team'; $youremail = 'craig@go4home.co.uk'; $subject = "Thankyou for registering with $yoursite, please activate your account..."; $message = "Dear $forename, Thankyou for registering with us at $yoursite Your registered details are shown below: Username: $username Password: $password For better security and to fully activate your account, please click the link provided below: <a href="www.go4home.co.uk/activate.php?id={$username}"> activate account</a> If you cannot click on the above link, please copy and paste the following link into your web browser: <a href="www.go4home.co.uk/activate.php?id={$username}">www.go4home.co.uk/activate.php?id={$username}</a> Your Password: If at any time you need to change your password, please use the 'forgotten your password?' feature on our login page Please print this information out and store it for future reference. Thanks, $webmaster; Please do not reply to this email message, thankyou" mail($email, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion()); echo "A confirmation email has been mailed to your email address $email."; ?> </body> </html> register_success.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="Style1.css" /> <title>Go4home.co.uk - Find your dream property, or advertise your house for sale on the property market on go4home.co.uk</title> <meta name="Description" content="Find your dream property online, Search for any property for sale in a range of areas in the UK with go4home" /> <meta name="Keywords" content="Find a property, find property, find property in UK, search for a property, Property up for sale, find property up for sale, Property market, Advertise your home to sell, go4home.co.uk, go4home" /> </head> <body> <div id="mainContainer"> <div id="container-Content"> <div id="content-TopContent"> <div id="TopBar"> <div id="Logo"><img src="Images/Go4Home-logo.jpg" alt="Go4home.co.uk" width="201" height="39" /></div> <div id="myProfile"></div> <div id="Login"><a href="login_form.html">login</a></div> <div id="NotRegisteredText"><a class="blue" href="register.html">Not Registered?</a></div> </div><!--End of TopBar --> <ul id="navigationMenu"> <li class="HomeButton"><a href="index.html"></a></li> <li class="SearchButton"><a href="Construction Page.html"></a></li> <li class="MoneyMarketButton"><a href="Construction Page.html"></a></li> <li class="GoBuyButton"><a href="Construction Page.html"></a></li> <li class="GoSellButton"><a href="Construction Page.html"></a></li> <li class="HelpButton"><a href="Construction Page.html"></a></li> </ul> </div><!--End of content-Topcontent --> <div id="content-centrecontent"> <br /> <h2 class="shadow">Registration Successful!</h2> <br /> <p class="centreContent">Thankyou for registering with go4home.co.uk<br /> An activation email has been sent to your email account. Please check your email inbox and follow the instructions to<br /> activate your account <br /><br />Start the search for your dream property from the go4home <a class="large" href="index.html">home page</a></p> </div><!--End of content-centrecontent--> </div><!--End of container-Content--> <div id="footer"> <ul id="footerMenu"> <li><a href="Construction Page.html">Go4home terms & conditions</a></li> <li><a href="Construction Page.html">Accessibility</a></li> <li><a href="Construction Page.html">About Us</a></li> <li><a href="Construction Page.html">Privacy Policy</a></li> <li><a href="Construction Page.html">Contact Us</a></li> </ul> <div id="CopyrightText"></div> </div><!--End of footer --> </div><!--End of mainContainer--> </body> </html> Some feedback or insight would be great cheers Craig Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 19, 2008 Share Posted February 19, 2008 What you want to use is the header() function to forward the page. In register_process.php, Get rid of all the HTML before and after the PHP code. Then, after you send the email, use header() like so: <?php ... mail($email, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion()); header('Location: register_success.html'); exit; ?> Quote Link to comment Share on other sites More sharing options...
barbs75 Posted February 19, 2008 Author Share Posted February 19, 2008 Hey Aaron, cheers for your help, worked wonders!! Another question, you couldnt take a little look at another one of my topics at: http://www.phpfreaks.com/forums/index.php/topic,183157.0.html Its just regarding php navigation, if you no anything about this subject i would greatly receive your input!! cheers again Craig 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.