im working on a project that will allow users to first enter a serial number then confirm their details.
my database looks like:
database name USERS
Table name uniq
ID (primary key)
ClientID not null
ClientName not null
SerialNo not null
InvoiceNo not null
ReceiveDate not null
ClientVerDate null
ClientVerified null
ClientAddress null
Basically, all the fields not null are known to me and are currently stored in my database.
I have 4 files Index.php , Validate.php , Config.php , Page.php(just my html split up into variables $p1 and $p2)
index.php is a form that asks the user for their serial number(SerialNo)
this info is passed to validate.php where i collect all known data in the database related to SerialNo
Validate.php displays the known data which again is everything from above marked not null.
So far so good although i am a noob and if there are better ways to do this please feel free to comment.
Now, i want to get the clients address to validate their application. This is where im way off the mark and need
help.
as im currently doind it, it loops through all entries in the database and screws up my records. im going to post
the code below but beware it is wrong.
I hope someone can make sense of what im trying to do here and point me in the right direction. What i want to
happen is, the user enters their address and hits submit. The script then adds the address to the Database field
ClientAddress, adds the current date to ClientVerDate and adds the value 'true' to the field ClientVerified. The
submitted information obviously has to apply to the correct user as identified by the serial they enter. I then
want to display a thank you type of message when the data has been added to the database. what is the correct way
to do this?
my database looks like:
database name USERS
Table name uniq
ID (primary key)
ClientID not null
ClientName not null
SerialNo not null
InvoiceNo not null
ReceiveDate not null
ClientVerDate null
ClientVerified null
ClientAddress null
Basically, all the fields not null are known to me and are currently stored in my database.
I have 4 files Index.php , Validate.php , Config.php , Page.php(just my html split up into variables $p1 and $p2)
index.php is a form that asks the user for their serial number(SerialNo)
this info is passed to validate.php where i collect all known data in the database related to SerialNo
Validate.php displays the known data which again is everything from above marked not null.
Code:
$serial = $_POST['serial'];
// Get all the data from the "uniq" table and match to serial
$result = mysql_query("SELECT * FROM uniq" . " WHERE SerialNo like \"%$serial%\" ")
or die(mysql_error());
echo "$p1";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row and allow user to contact if wrong details
echo "<p>If This is not you, <a href=\"contact.php\">Please click here</a></p>";
echo "<p>";
echo 'NAME: ' .$row['ClientName'];
echo "</p><p>";
echo 'ClientID: ' .$row['ClientID'];
echo "</p><p>";
echo 'INVOICE NUMBER: ' .$row['InvoiceNo'];
echo "</p><p>";
echo 'DATE RECEIVED: ' .$row['ReceiveDate'];
echo "</p><br /><p>";
echo "<h2>Please enter your address below to verify your warranty</h2></p><p>";
echo 'ADDRESS: ' .$row['ClientAddress'];
echo "</p>";
}
So far so good although i am a noob and if there are better ways to do this please feel free to comment.
Now, i want to get the clients address to validate their application. This is where im way off the mark and need
help.
as im currently doind it, it loops through all entries in the database and screws up my records. im going to post
the code below but beware it is wrong.
Code:
if ($row['ClientAddress'] == NULL){
echo "
<p><h2>Please enter your address below to verify your warranty</h2></p>
<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">
<textarea name=\"address\" rows=\"10\" cols=\"40\"> </textarea>
<p><input type=\"submit\" name=\"submitaddress\" value=\"Verify Warranty\"></p>
</form> "
;}
if (isset($_POST['submitaddress'])) {
$address = $_POST['address'];
$sql = ("UPDATE uniq SET
ClientAddress='$address',
ClientVerDate=CURDATE(),
ClientVerified="true"
WHERE SerialNo like \"%$serial%\"
");
if (@mysql_query($sql)) {
echo ('<p>thank you, you are verified</p>');
} else {
echo ('<p>error adding address:' .mysql_error().'</p>');
}
}
I hope someone can make sense of what im trying to do here and point me in the right direction. What i want to
happen is, the user enters their address and hits submit. The script then adds the address to the Database field
ClientAddress, adds the current date to ClientVerDate and adds the value 'true' to the field ClientVerified. The
submitted information obviously has to apply to the correct user as identified by the serial they enter. I then
want to display a thank you type of message when the data has been added to the database. what is the correct way
to do this?