grantp22 Posted October 3, 2009 Share Posted October 3, 2009 Hi can anybody help me with this problem, I have a simple login form that I created for testing on localhost that submits username and password to process.php, but when process.php is called the brower outputs the code content of process.php and nothing actually gets processed. Session.php is included in the login form, which includes process.php and vice versa, but thats not really important. This whole setup works perfectly on my webhost but refuses to work on localhost. For simplicity I have cut down this code to a basic login form... All of my other php pages are displaying perfectly on localhost, it is only when I try and post data, that process.php refuses to co-operate and all internal code for process.php is outputted in the browser, what can be causing this? I have included code below, if anybody wants to check it! Here is the basic login form... <?php include("include/session.php"); ?> <html> <title>Simple Login Script</title> <body> <table> <tr><td> <form action="process.php" method="POST"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<?php echo $form->value("user"); ?>"></td><td><?php echo $form->error("user"); ?></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<?php echo $form->value("pass"); ?>"></td><td><?php echo $form->error("pass"); ?></td></tr> <tr><td colspan="2" align="left"><input type="checkbox" name="remember" <?php if($form->value("remember") != ""){ echo "checked"; } ?>> <font size="2">Remember me next time <input type="hidden" name="sublogin" value="1"> <input type="submit" value="Login"></td></tr> <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr> <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr> </table> </form> </td></tr> </table> </body> </html> And here is the complete code for process.php <?php /** * Process.php */ include("include/session.php"); class Process { /* Class constructor */ function Process(){ global $session; /* User submitted login form */ if(isset($_POST['sublogin'])){ $this->procLogin(); } /* User submitted registration form */ else if(isset($_POST['subjoin'])){ $this->procRegister(); } /* User submitted forgot password form */ else if(isset($_POST['subforgot'])){ $this->procForgotPass(); } /* User submitted edit account form */ else if(isset($_POST['subedit'])){ $this->procEditAccount(); } /** * User wants to logout. */ else if($session->logged_in){ $this->procLogout(); } /** * User is viewing this page by mistake so redirect. */ else{ header("Location: index.php"); } } /** * procLogin - Processes the user submitted login form, if errors * are found, the user is redirected to correct the information, * if not, the user is effectively logged in to the system. */ function procLogin(){ global $session, $form; /* Login attempt */ $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember'])); /* Login successful */ if($retval){ header("Location: index.php"); } /* Login failed */ else{ $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); header("Location: ".$session->referrer); } } /** * procLogout - Attempt to log the user out of the system */ function procLogout(){ global $session; $retval = $session->logout(); header("Location: index.php"); } /** * procRegister - Process user submitted registration form, * if errors are found, the user is redirected to correct the * information, if not, the user is effectively registered with * the system and an email is (optionally) sent to the newly * created user. */ function procRegister(){ global $session, $form; /* Convert username to all lowercase (by option) */ if(ALL_LOWERCASE){ $_POST['user'] = strtolower($_POST['user']); } /* Registration attempt */ $retval = $session->register($_POST['fname'], $_POST['sname'], $_POST['address'], $_POST['city'], $_POST['pcode'], $_POST['mobile'], $_POST['email'], $_POST['user'], $_POST['pass'], $_POST['pass2'], $_POST['fmail1'], $_POST['fmail2']); /* Registration Successful */ if($retval == 0){ $_SESSION['reguname'] = $_POST['user']; $_SESSION['regsuccess'] = true; header("Location: ".$session->referrer); } /* Error found with form */ else if($retval == 1){ $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); header("Location: ".$session->referrer); } /* Registration attempt failed */ else if($retval == 2){ $_SESSION['reguname'] = $_POST['user']; $_SESSION['regsuccess'] = false; header("Location: ".$session->referrer); } } /** * procForgotPass - Validate given username, if ok * new password is generated and emailed to the * email address the user gave on sign up. */ function procForgotPass(){ global $database, $session, $mailer, $form; /* Username error checking */ $subuser = $_POST['user']; $field = "user"; //Use field name for username if(!$subuser || strlen($subuser = trim($subuser)) == 0){ $form->setError($field, "Username not entered<br>"); } else{ /* Make sure username is in database */ $subuser = stripslashes($subuser); if(strlen($subuser) < 5 || strlen($subuser) > 30 || !eregi("^([0-9a-z])+$", $subuser) || (!$database->usernameTaken($subuser))){ $form->setError($field, "Username does not exist<br>"); } } /* Errors exist, have user correct them */ if($form->num_errors > 0){ $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); } /* Generate new password and email it to user */ else{ /* Generate new password */ $newpass = $session->generateRandStr(; /* Get email of user */ $usrinf = $database->getUserInfo($subuser); $email = $usrinf['email']; /* Attempt to send the email with new password */ if($mailer->sendNewPass($subuser,$email,$newpass)){ /* Email sent, update database */ $database->updateUserField($subuser, "password", md5($newpass)); $_SESSION['forgotpass'] = true; } /* Email failure, do not change password */ else{ $_SESSION['forgotpass'] = false; } } header("Location: ".$session->referrer); } /** * procEditAccount - Attempt to edit the user's account * information, including the password, which must be verified * before change is made. */ function procEditAccount(){ global $session, $form; /* Account edit attempt */ $retval = $session->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email']); /* Account edit successful */ if($retval){ $_SESSION['useredit'] = true; header("Location: ".$session->referrer); } /* Error found with form */ else{ $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); header("Location: ".$session->referrer); } } }; /* Initialize process */ $process = new Process; ?> And finally this is small portion of what is being outputted in the browser when process.php is called... procLogin(); } /* User submitted registration form */ else if(isset($_POST['subjoin'])){ $this->procRegister(); } /* User submitted forgot password form */ else if(isset($_POST['subforgot'])){ $this->procForgotPass(); } /* User submitted edit account form */ else if(isset($_POST['subedit'])){ $this->procEditAccount(); } /** * The only other reason user should be directed here * is if he wants to logout, which means user is * logged in currently. */ else if($session->logged_in){ $this->procLogout(); } /** * Should not get here, which means user is viewing this page * by mistake and therefore is redirected. */ else{ header("Location: index.php"); } } /** * procLogin - Processes the user submitted login form, if errors * are found, the user is redirected to correct the information, * if not, the user is effectively logged in to the system. */ function procLogin(){ global $session, $form; /* Login attempt */ $retval = $session->login($_POST['user'], $_POST I have gone through everything and can't find a reason why this is happening code wise, so I am assuming it has to do with a php configuration issue, but I am not sure! I anybody has run into this problem before, can you please give me an idea of where to go to troubleshoot this Thanks Grant Quote Link to comment https://forums.phpfreaks.com/topic/176426-why-does-processphp-only-show-code-and-not-process-submitted-data/ Share on other sites More sharing options...
ProXy_ Posted October 4, 2009 Share Posted October 4, 2009 install the newest PHP on your computer and you'll need to enable php in your Server. php: http://www.php.net/downloads.php Quote Link to comment https://forums.phpfreaks.com/topic/176426-why-does-processphp-only-show-code-and-not-process-submitted-data/#findComment-929969 Share on other sites More sharing options...
cags Posted October 4, 2009 Share Posted October 4, 2009 install the newest PHP on your computer and you'll need to enable php in your Server. php: http://www.php.net/downloads.php I don't see how that will make any difference since if you read the OP's full post... All of my other php pages are displaying perfectly on localhost, Quote Link to comment https://forums.phpfreaks.com/topic/176426-why-does-processphp-only-show-code-and-not-process-submitted-data/#findComment-930063 Share on other sites More sharing options...
PFMaBiSmAd Posted October 4, 2009 Share Posted October 4, 2009 The problem is occurring because the process.php file not not being parsed as php code. You have somehow either browsed directly to the file or the file extension is not actually .php or it is in a folder where the php language engine is not enabled. Quote Link to comment https://forums.phpfreaks.com/topic/176426-why-does-processphp-only-show-code-and-not-process-submitted-data/#findComment-930098 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.