Jump to content

Recommended Posts

Having a problem w/ a self-submitting form.... 1st submission everything seems to work correct.  Every subsequent submission all of the $_POST data gets dropped.  I enter data into the fields, but NONE of it carries forward.... I've been fighting this #@%& thing all day :facewall:  If anyone has any insight, please help!!  Here's the page pared down to the essentials.  TIA!!

 

<?php

session_start();

function db_open() {

$dbUser="sqluser";

$dbPass="sqlpass";

$dbName="sqlname";

$dbHost="$localhost";

if(!($link=mysql_connect($dbHost, $dbUser, $dbPass))) {

echo('Connect Error');

}

if(!mysql_select_db($dbName,$link)) {

echo('Select Error');

}

return($link);

}

$thispage = $_SERVER['PHP_SELF'];

$connection=db_open();

 

$userpw=$_POST['userpw'];

$email=$_POST['email'];

if($_POST['Submit']=='Login')

{

if($email==""){

$errmsg='e-mail cannot be blank!';

}

else if($userpw==""){

$errmsg='Password Required!';

}

else {

$qry="SELECT * FROM client WHERE email='$email'";

$result=mysql_query($qry);

$tmpmessage='Returned '.mysql_num_rows($result).' Rows';

$userdata=mysql_fetch_row($result);

var_dump($userdata); // Debug

if(mysql_num_rows($result)!=1) {

$errmsg='Sorry, we have no record of this email address.';

} else if($userpw==$userdata[11]) {

$client_id=$userdata[0]; $client_firstname=$userdata[2]; $client_lastname=$userdata[1];

$_SESSION['client_id']=$client_id;

$_SESSION['client_firstname']=$client_firstname;

$_SESSION['client_lastname']=$client_lastname;

} else {

$errmsg='The password provided does not match our records.';

 

};

};

};

 

 

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Test Document</title>

</head>

<body>

<form action="<?php echo $thispage; ?>" method="post" name="form1" target="_self" id="form1">

<table width="623" border="0">

  <tr>

    <td width="45"> </td>

    <td width="258"> </td>

    <td width="207"> </td>

    <td width="95"> </td>

  </tr>

  <tr>

    <td> </td>

    <td colspan="2"><?php echo $errmsg; ?></td>

    <td> </td>

  </tr>

 

  <tr>

    <td> </td>

    <td style="text-align: right">email</td>

    <td><input type="text" name="email" id="textfield" value="<?php echo $email; ?>" /></td>

    <td> </td>

  </tr>

  <tr>

    <td> </td>

    <td style="text-align: right">password</td>

    <td><input type="password" name="userpw" id="userpw" value="<?php echo $userpw ?>" /></td>

    <td> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td><input type="submit" name="Submit" id="Submit" value="Login" /></td>

    <td> </td>

  </tr>

 

</table>

</form>

 

</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/169556-problem-w-self-submission/
Share on other sites

It seems he has it linked, but yes it is wise to do it directly for debugging such as this.

 

target="_self"

 

Could that be the problem? It might be submitting the second time, into the wrong place, I can't see anything that would otherwise muck up subsequent submits..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.