Jump to content

Help about Log-in Filters that Ping Pong on this php.


markymark

Recommended Posts

1st the log in code:

Code

<form method ="post" action="cartnisya.php">

<table border="0"align="right">

<td>Username:</td>

<td><input type="Text" name="Username"></td>

<td>&nbsp </td>

<td>&nbsp </td>

<td>Password:</td>

<td><input type="Password" name="Password"></td>

<td>&nbsp </td>

<td colspan="2" align="center"><input type="Submit" name=submit" value="Submit"></td>

</table>

<img src="Vinnex1.jpg">

 

 

</form>

 

it will then go the php code:

CODE:

<html>

<?php

$db = mysql_connect("localhost", "root","");

mysql_select_db("vinnex",$db);

$Username = $_POST['Username'];

echo $Username;

$result = mysql_query("Select TransNo From transaction", $db);

$myrow = mysql_fetch_array($result);

if ($myrow=='')

{

$TransNo='1000';

$sql = mysql_query("Select * From customer where Username='$Username'", $db);

$myrow1 = mysql_fetch_array($sql);

$Username = $myrow1['Username'];

$Firstname = $myrow1['Firstname'];

$Lastname = $myrow1['Lastname'];

$name = $Firstname. " ".$Lastname;

$Date = date('m/d/y');

$sql1 = "INSERT INTO temptransaction (TransNo, Username, Firstname, Date)

  VALUES ('$TransNo', '$Username', '$Firstname', '$Date')";

$result = mysql_query($sql1); //or die(mysql_error());

}

else

{

$sql = mysql_query("Select max(TransNo) maxTransNo From transaction", $db);

$myrow1 = mysql_fetch_array($sql);

$orderno = $myrow1['maxTransNo']+1;

$sql = mysql_query("Select * From customer where Username='$Username'", $db);

$myrow1 = mysql_fetch_array($sql);

$Username = $myrow1['Username'];

$Firstname = $myrow1['Firstname'];

$Lastname = $myrow1['Lastname'];

$name = $Firstname. " ".$Lastname;

$Date = date('m/d/y');

$sql1 = " INSERT INTO temptransaction (TransNo, Username, Firstname, Date)

  VALUES ('$TransNo', '$Username', '$Firstname', '$Date')";

$result = mysql_query($sql1) or die(mysql_error());

}

?>

<meta http-equiv="refresh" content="0;url=orderproduct.html"/>

</html>

 

once this is open it will go the selected it wont display the matched echo for the text field. once i call the database when using username and password it wont filter and it wont call for a firstname and username to be saved in the database please help

Link to comment
Share on other sites

It helps to use the [ code ] snips

 

<form method ="post" action="cartnisya.php">
<table border="0"align="right">
   <td>Username:</td>
   <td><input type="Text" name="Username"></td>
   <td>&nbsp </td>
   <td>&nbsp </td>
   <td>Password:</td>
   <td><input type="Password" name="Password"></td>
   <td>&nbsp </td>
   <td colspan="2" align="center"><input type="Submit" name=submit" value="Submit"></td>
</table>
<img src="Vinnex1.jpg">   


</form>

it will then go the php code:
CODE:

<?php
$db = mysql_connect("localhost", "root","");
mysql_select_db("vinnex",$db);
$Username = $_POST['Username'];
echo $Username; // is this necessary in a processing file?
$result = mysql_query("Select TransNo From transaction", $db);
$myrow = mysql_fetch_array($result);
if ($myrow==null) //null is script friendly :]
{
   $TransNo='1000';
   $sql = mysql_query("Select * From customer where Username='$Username'", $db);
   $myrow1 = mysql_fetch_array($sql);
   $Username = $myrow1['Username'];
   $Firstname = $myrow1['Firstname'];
   $Lastname = $myrow1['Lastname'];
   $name = "$Firstname $Lastname"; //first last
   $Date = date('m/d/y');
   $sql1 = "INSERT INTO temptransaction (TransNo, Username, Firstname, Date)
           VALUES ('$TransNo', '$Username', '$Firstname', '$Date')";
   $result = mysql_query($sql1); //or die(mysql_error()); 

// you are inserting data into table: temptransaction, pulled from customer
}
else
{
   $sql = mysql_query("Select MAX(TransNo) AS maxTransNo From transaction", $db); // added as statement
   $myrow1 = mysql_fetch_array($sql);
   $orderno = $myrow1['maxTransNo']+1;
   $sql = mysql_query("Select * From customer where Username='$Username'", $db);
   $myrow1 = mysql_fetch_array($sql);
   $Username = $myrow1['Username'];
   $Firstname = $myrow1['Firstname'];
   $Lastname = $myrow1['Lastname'];
   $name = "$Firstname $Lastname"; //first last
   $Date = date('m/d/y');

// fixed spacing in insert statement primary cause
   $sql1 = "INSERT INTO temptransaction (TransNo, Username, Firstname, Date)
           VALUES ('$TransNo', '$Username', '$Firstname', '$Date')";
   $result = mysql_query($sql1) or die(mysql_error());
}
header("Location: /orderproduct.html"); //added header redirect
?>
<!--// Removed meta refresh... this method should be considered deprecated in html coding xD //-->
<html>
</html>

 

 

The table for your users is "Username" not username correct?

Link to comment
Share on other sites

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.