giannis Posted September 25, 2010 Share Posted September 25, 2010 Hello, I have the following code: <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" name="loginform" id="loginform" class="niceform" "> The problem is that the code isn't executed after the action="<?php echo $_SERVER['REQUEST_URI']; ?>" so the result doesn't have css. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/214354-php-cancels-html-execution/ Share on other sites More sharing options...
Pikachu2000 Posted September 25, 2010 Share Posted September 25, 2010 You need to post more than just that one line, but you do have an extra quote in there. Is the file saved as a .php or a .html file? Quote Link to comment https://forums.phpfreaks.com/topic/214354-php-cancels-html-execution/#findComment-1115465 Share on other sites More sharing options...
giannis Posted September 25, 2010 Author Share Posted September 25, 2010 The hole code is here and is .php <?php include "connect.php"; session_start(); session_register("session"); $empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>Click <a class=\"two\" href=\"javascript:history.go(-1)\">here</a> to go back"; $email = $_POST['email']; if (!isset($_POST['email'])) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Password Retrieval</title> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.ketchup.js"></script> <script type="text/javascript" src="js/jquery.ketchup.messages.js"></script> <script type="text/javascript" src="js/jquery.ketchup.validations.basic.js"></script> <script language="javascript" type="text/javascript" src="niceforms.js"></script> <link rel="stylesheet" type="text/css" media="all" href="niceforms-default.css" /> <link rel="stylesheet" type="text/css" media="screen" href="css/jquery.ketchup.css" /> </head> <body> <div id="container"> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" name="loginform" id="loginform" class="niceform" "> <fieldset> <legend>Forgot your password?</legend> <p>Please type your email address</p> <dl> <dt><label for="email">Email address:</label><br /></dt> <dd><input type="text" name="email" id="email" rel="validate(required,email)"/></dd> </dl> <dl> <dt> <dd><input type="submit" name="send_password" id="send_password" value="Send password" /> </dd> </dt> </dl> </fieldset> </form> <?php $empty_fields_message = "<h1><p>Please go back and complete all the fields in the form.</p>Click <a class=\"two\" href=\"javascript:history.go(-1)\">here</a> to go back<h1>"; } elseif (empty($email)) { echo $empty_fields_message; } else { $email_address=mysql_real_escape_string($email); $status = "OK"; $msg=""; if (!stristr($email,"@") OR !stristr($email,".")) { $msg="Your email address is not correct<BR>"; $status= "NOTOK";} echo "<br><br>"; if($status=="OK") { $query="SELECT email,username FROM users WHERE users.email = '$email'"; $st=mysql_query($query); $recs=mysql_num_rows($st); $row=mysql_fetch_object($st); $em=$row->$email; if ($recs == 0) { echo "<b>No Password</b><br> Sorry Your address is not in our database . You can signup to our site here"; exit;} 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); $sql = mysql_query("UPDATE users SET password='$db_password' WHERE email='$email'"); $subject = "Your new password at www.domain.com"; $message = "Hi, we have reset your password. New Password: $random_password http://www.domain.com/login Once logged in you can change your password Thanks! This is an automated response, please do not reply :-)"; mail($email_address, $subject, $message, "From: domain.com Webmaster<admin@domain.com>\n " ); ?> <div id="container"> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" name="loginform" id="loginform" class="niceform" "> <fieldset> <p>Your password has been sent! Please check your email!<br/></p> <p>Click <a href='http://test.homeguide.gr'>here</a> to login</p> <p>Members area is loading.</p> <meta http-equiv='refresh' content='=100;index.php' /> </fieldset> </form> </div> <?php } else {echo "<center><font face='Verdana' size='2' color=red >$msg <br><br><input type='button' value='Retry' onClick='history.go(-1)'></center></font>";} } ?> </div> <script type = "text/javascript"> $(document).ready(function() { $('#loginform').ketchup(); }); </script> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/214354-php-cancels-html-execution/#findComment-1115467 Share on other sites More sharing options...
Pikachu2000 Posted September 25, 2010 Share Posted September 25, 2010 I pasted in the html locally and it seems fine here. The only problem that jumps out at me is the extra quote present near the end of both <form " "> tags. Quote Link to comment https://forums.phpfreaks.com/topic/214354-php-cancels-html-execution/#findComment-1115471 Share on other sites More sharing options...
giannis Posted September 25, 2010 Author Share Posted September 25, 2010 I deleted the extra " , but the message <<Your password has been sent! Please check your email!>> is still out of the css Quote Link to comment https://forums.phpfreaks.com/topic/214354-php-cancels-html-execution/#findComment-1115472 Share on other sites More sharing options...
giannis Posted September 26, 2010 Author Share Posted September 26, 2010 <?php include "connect.php"; session_start(); session_register("session"); $empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>Click <a class=\"two\" href=\"javascript:history.go(-1)\">here</a> to go back"; $email = $_POST['email']; if (!isset($_POST['email'])) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Password Retrieval</title> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.ketchup.js"></script> <script type="text/javascript" src="js/jquery.ketchup.messages.js"></script> <script type="text/javascript" src="js/jquery.ketchup.validations.basic.js"></script> <script language="javascript" type="text/javascript" src="niceforms.js"></script> <link rel="stylesheet" type="text/css" media="all" href="niceforms-default.css" /> <link rel="stylesheet" type="text/css" media="screen" href="css/jquery.ketchup.css" /> </head> <body> <div id="container"> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" name="loginform" id="loginform" class="niceform" > <fieldset> <legend>Forgot your password?</legend> <p>Please type your email address</p> <dl> <dt><label for="email">Email address:</label><br /></dt> <dd><input type="text" name="email" id="email" rel="validate(required,email)"/></dd> </dl> <dl> <dt> <dd><input type="submit" name="send_password" id="send_password" value="Send password" /> </dd> </dt> </dl> </fieldset> </form> <?php } else if (empty($email)) { ?> <div id="container"> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" name="loginform" id="loginform" class="niceform" > <fieldset> <legend>please go back and complete all the fields in the form</legend> <p>Click <a class=\"two\" href=\"javascript:history.go(-1)\">here</a> to go back</p> </fieldset> </form> </div> Why doesn't the class="niceform" execute the second time we call the form? Quote Link to comment https://forums.phpfreaks.com/topic/214354-php-cancels-html-execution/#findComment-1115875 Share on other sites More sharing options...
Pikachu2000 Posted September 26, 2010 Share Posted September 26, 2010 Your whole html page header section is inside the conditional, DOCTYPE, <head>, <title>, everything. It only gets sent to the browser if the form hasn't been submitted. You need to rework that bit of logic so it gets sent regardless of whether the form has been submitted. Quote Link to comment https://forums.phpfreaks.com/topic/214354-php-cancels-html-execution/#findComment-1115878 Share on other sites More sharing options...
giannis Posted September 27, 2010 Author Share Posted September 27, 2010 Thank you for your help, I solved the problem! :-) Quote Link to comment https://forums.phpfreaks.com/topic/214354-php-cancels-html-execution/#findComment-1116181 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.