Jump to content

php cancels html execution


giannis

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/214354-php-cancels-html-execution/
Share on other sites

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<[email protected]>\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>

       
       

            

<?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?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.