Page 1 of 1

Form not doing what it should

Posted: Fri Feb 13, 2004 6:13 pm
by pinehead18
Ok, this is my code. However it used to work now all of sudden it does not.

When i fill out the form and hit submit the page just reloads and does nothing

When i replace the send_pass() with echo $email;

it echo's correctly. Which leads me to assume the probelm lies in send_pass(); Yet for the life of me i can't find it. I've commented out stuff and re-wrote stuff yet nothing.

maby it is somethign ic an't see (its 6:15pm and i've been up since 3am) so who knows
thanks for your help

Code: Select all

<?PHP

function send_pass() {

	$con = mysql_connect("localhost","p","") or die(mysql_error());
	$db = mysql_select_db("pinehead",$con) or die(mysql_error());
	$sql = "SELECT pass FROM users WHERE email='$email'";
	$result = mysql_query($sql,$con) or die(msql_error());
	$row = mysql_fetch_array($result);

                $pass = $row['pass'];
	echo $email;
	echo $pass;

      //  $body = "
    //    Account information for C.com:
  //      In order to change your password click on the following link and enter your new password.
//
  //       http:///resetpass.php?uname=$user&pass=$pass
//
  //      Thank you for helping build our community at C.com
//
  //      Sincerely,

//        People in Kansas City Staff";
//        mail($email, "Your account information at .com", $body, "FROM: support@");

//	 $sent_message .= "<center><font face=arial color=red size=-1>Your password/username has been sent to $email";
}


if ($_POST['submit']) {


	send_pass();
	
	}


$output .= "".$sent_message."
	<table border=1 bordercolor=475575 bgcolor=475575 cellspacing=0 cellpadding=0 align=center width=87%>
                <tr>
                        <td>Forgot your password? <font color=red face=arial size=-1>(This service is temporarily 
unavailable)</font></td>
                </tr>
        </table>
        <table bordercolor=475575 border=1 cellspacing=0 width=87% cellpadding=0 align=center>
        <tr>
                      <td>Forgot your password or your username? Enter your email address below and  will send your 
account information.</p>

<form method=post action=forgotpass.php>Enter your email: <input type=text name=email>&nbsp;<input type=submit value=Submit name=submit></form>

</td></tr></table>";



?>

Posted: Fri Feb 13, 2004 6:23 pm
by qads
well, i can see you are checking if the form has been submited or not with

if($_POST['.....

but i dont see you passing email field value with $_POST[' :P

you just need $_POST['email'], not $email.

Posted: Fri Feb 13, 2004 6:55 pm
by John Cartwright
Also,

this

Code: Select all

<?php
$output .= "".$sent_message." 
?>
should be

Code: Select all

<?php

$output = $sent_message;

?>

Posted: Fri Feb 13, 2004 7:00 pm
by John Cartwright
also

Code: Select all

<?PHP 

function send_pass() { 

   $con = mysql_connect("localhost","p","") or die(mysql_error()); 
   $db = mysql_select_db("pinehead",$con) or die(mysql_error()); 
   $sql = "SELECT pass FROM users WHERE email='$email'"; 
   $result = mysql_query($sql,$con) or die(msql_error()); 
   $row = mysql_fetch_array($result); 
   $pass = $row['pass']; 
   
   echo $email; 
   echo $pass; 

      //  $body = " 
    //    Account information for C.com: 
  //      In order to change your password click on the following link and enter your new password. 
// 
  //       http:///resetpass.php?uname=$user&pass=$pass 
// 
  //      Thank you for helping build our community at C.com 
// 
  //      Sincerely, 

//        People in Kansas City Staff"; 
//        mail($email, "Your account information at .com", $body, "FROM: support@"); 

//    $sent_message = "<center><font face=arial color=red size=-1>Your password/username has been sent to $email"; 
} 


if (SubmitMail == SUBMIT) { 


   send_pass(); 
    
   } 


$output = $sent_message ?>

<table border=1 bordercolor=475575 bgcolor=475575 cellspacing=0 cellpadding=0 align=center width=87%> 
                <tr> 
                        <td>Forgot your password? <font color=red face=arial size=-1>(This service is temporarily 
unavailable)</font></td> 
                </tr> 
        </table> 
        <table bordercolor=475575 border=1 cellspacing=0 width=87% cellpadding=0 align=center> 
        <tr> 
                      <td>Forgot your password or your username? Enter your email address below and  will send your 
account information.</p> 

<form method=post action=forgotpass.php>Enter your email: <input type=text name=email> <input type=submit value=SubmitMail name=submit></form> 

</td></tr></table>"; 



?>
Just made a few minor changes (syntax errors)