mfleming Posted October 23, 2010 Share Posted October 23, 2010 Hi. Me next question, is how to I send variable from one page to another page. Example: Form Page checks user inputed values, updates database then uses // Thank you Page $insertGoTo = "changepass.php"; header(sprintf("Location: %s", $insertGoTo)); to redirect users to Confirmation page. Confirmation page: Checks to make sure values where properly stored in datebase and says "YES IT WORKED" OR "NO, SOMETHING WENT WRONG" Current Code: <?php session_start(); ?> <?php $submit = $_POST['submit']; // Form Data $email = $_POST['email']; $password_old = $_POST['password_old']; $password_new = $_POST['password_new']; $password_new_con = $_POST['password_new_con']; $errorcount = 0; // Edit anything inbetween the " " for the display error message $errormsg['Email'] = "Email Entered is not in our database"; $errormsg['OldPass'] = "Old Password Entered is Incorrect. Please check your Email"; $errormsg['NewPass'] = "New Password must be between 6 and 32 characters"; $errormsg['NewPassCon'] = "New Passwords do not match."; $errormsg['SecCode'] = "Security Code is Invalid"; $errormsg['dbPass'] = "Invalide Email or activation code. Please Contact <a href='mailto:[email protected]?subject=Fusion Fashion Hair - Member Activation Error%20Request'>Admin</a>"; $errormsg['NoErr'] = "No Errors, Continue"; $errormsg['PlaceHold'] = ""; $errortrack[] = $errormsg['PlaceHold']; if ($_POST[submit]){ if ($errorstop = "go") { $errorstop="go"; while ($errorstop<>"stop") { //Check for security code if ($_SESSION[key]==$_POST[user_code]){ // echo "True - Continue 0"; // echo "<p>----------</p>"; $_SESSION[key]=''; } else { // echo "False - Stop 0"; $errortrack[] = $errormsg['SecCode']; $errorcount++; $errorstop="stop"; } // check for existance if (!checkEmail($email)) { // echo "False - Stop 1"; $errortrack[] = $errormsg['Email']; $errorcount++; $errorstop="stop"; } else { // echo "True - Continue 1"; // echo "<p>----------</p>"; } // check for existance if (strlen($password_old)>5) { // echo "True - Continue 2"; // echo "<p>----------</p>"; } else { // echo "False - Stop 2"; $errortrack[] = $errormsg['OldPass']; $errorcount++; $errorstop="stop"; } // check for existance if (strlen($password_new)>32||strlen($password_new)<6) { // echo "False - Stop 3"; $errortrack[] = $errormsg['NewPass']; $errorcount++; $errorstop="stop"; } else { // echo "True - Continue 3"; // echo "<p>----------</p>"; } // check for existance if ($password_new_con==$password_new) { // echo "True - Continue 4"; // echo "<p>----------</p>"; $errorstop="stop";//Get Out of loop } else { // echo "False - Stop 4"; $errortrack[] = $errormsg['NewPassCon']; $errorcount++; $errorstop="stop"; } }//End While Loop // Check database require('dbConfig.php'); // Encrypts old password to check with Database Encryped Password $password_old = md5($password_old); $check = mysql_query("SELECT * FROM {$usertable} WHERE email='$email' AND password='$password_old'"); $checknum = mysql_num_rows($check); if ($checknum==1) { // echo "True - Continue 5 Set password"; // echo "<p>----------</p>"; // Encrypts new password $password = md5($password_new); //run a query to update the account $acti = mysql_query("UPDATE {$usertable} SET password='$password' WHERE email='$email'"); } else { // echo "False - Stop 5"; $errortrack[] = $errormsg['dbPass']; $errorcount++; $errorstop="stop"; }//End if checknum // echo "True - Continue 6 GO TO HEADER PAGE"; // Thank you Page $insertGoTo = "changepass.php"; header(sprintf("Location: %s", $insertGoTo)); } else { while($errorcount>=0) { // Test display all error messages // echo "<p>----------</p>"; // echo "<p>Error Count = '$errorcount'</p>"; } die ("PLEASE FILL IN ALL FIELDS"); } } ?> <?php // LINUX PLATFORM OPTION 3 // checkEmail function checks standard email format same as preg_match() // checkEmail function checks DSN records using checkdnsrr Use list() to seperate name and domain using split function // checkdnsrr ONLY WORKS on LINUX PLATFORM // Check to see if domain and username is active // uses fsockopen() to check if its in use using port 25 function checkEmail($email) { // checks proper syntax if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $email)) { // gets domain name list($username,$domain)=split('@',$email); // checks for if MX records in the DNS if(!checkdnsrr($domain, 'MX')) { return false; } return true; } return false; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/216626-taking-form-values-from-php-page-to-php-page/ Share on other sites More sharing options...
trq Posted October 23, 2010 Share Posted October 23, 2010 The easiest way to keep variables from page to page is probably to stick them within the $_SESSION array. Quote Link to comment https://forums.phpfreaks.com/topic/216626-taking-form-values-from-php-page-to-php-page/#findComment-1125489 Share on other sites More sharing options...
mfleming Posted October 23, 2010 Author Share Posted October 23, 2010 based on my code, how would I add $email and $password_new. This way I can send an email to the user with EMAIL & PASSWORD changed and if email sent successfully using GET from my Confirmation page, would display email sent or email not sent? Quote Link to comment https://forums.phpfreaks.com/topic/216626-taking-form-values-from-php-page-to-php-page/#findComment-1125498 Share on other sites More sharing options...
trq Posted October 23, 2010 Share Posted October 23, 2010 Sorry, but very little of that last post made any sense to me. Quote Link to comment https://forums.phpfreaks.com/topic/216626-taking-form-values-from-php-page-to-php-page/#findComment-1125500 Share on other sites More sharing options...
mfleming Posted October 23, 2010 Author Share Posted October 23, 2010 Sorry. How do I add variable to the SESSION array? And how do I retrieve these in a new web page? Quote Link to comment https://forums.phpfreaks.com/topic/216626-taking-form-values-from-php-page-to-php-page/#findComment-1125503 Share on other sites More sharing options...
trq Posted October 23, 2010 Share Posted October 23, 2010 page1.php <?php session_start(); $_SESSION['var'] = 'hello'; page2.php <?php session_start(); if (isset($_SESSION['var'])) { echo $_SESSION['var']; } Quote Link to comment https://forums.phpfreaks.com/topic/216626-taking-form-values-from-php-page-to-php-page/#findComment-1125504 Share on other sites More sharing options...
mfleming Posted October 23, 2010 Author Share Posted October 23, 2010 Perfect, Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/216626-taking-form-values-from-php-page-to-php-page/#findComment-1125679 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.