A
Anonymous
Guest
First read this article HERE. Actually i think that a similar article should be posted on every forum....
Ok now straight to the point, I really dont have time to write out the code, but i can give you guidelines and hopefully some examples that you will have to develop into the code by yourself.
Now you say that your Mysql database is located on a different server and thats ok since the parameters of mysql_connect() or mysql_pconnect() functions are: mysql_connect("host","username","password").
Ok i hope that you know how to setup the html form that you will need to facilitate the request. If not here's an example
On the next page you would have to check whether the user put a value in, the value is only numeric (assuming your product numbers are numeric) and whether the length of that value is 6 (assuming that your product numbers are 6 digits in length). Then your program should connect to the database and search the for the key (product number).
Oh i probably should say this... if you are going to be entering more than one value in the first page, i would advise you to use arrays versus differently named variables.
Code wise, this part here may vary depending on what version of PHP the server that you are using has.
Well i have to leave you here, because i have to go.
Sorry i didnt have time to check the code or run it, but i hope it helps.
I think that what you would also have to do is on the page that i created you would need to create a hidden form (meaning all the inputs would be hidden) that will resent the variables to the page that will process the order and put it in the orders database. Instead of submit button in the form i would put "confirm order" button. The next page however only has to check the availability of the variables, since they have been processed in the prior page.
I'll try to put another post on tomorrow.
Ok now straight to the point, I really dont have time to write out the code, but i can give you guidelines and hopefully some examples that you will have to develop into the code by yourself.
Now you say that your Mysql database is located on a different server and thats ok since the parameters of mysql_connect() or mysql_pconnect() functions are: mysql_connect("host","username","password").
Ok i hope that you know how to setup the html form that you will need to facilitate the request. If not here's an example
Code:
<html>
<head></head>
<body>
<form action="our_confirmation_page.php" method="Post">
<input type="text" name="product_num" maxlength="6"><br>
<input type="reset" value="reset" name="reset">
<input type="submit" value="submit" name="submit">
</form>
</body>
</html>
Oh i probably should say this... if you are going to be entering more than one value in the first page, i would advise you to use arrays versus differently named variables.
Code wise, this part here may vary depending on what version of PHP the server that you are using has.
PHP:
<html>
<head></head>
<body>
<?php
$product_num=$HTTP_POST_VARS['product_num'];
if ($product_num==false)
{
die('No value was inserted');
}
if (ereg('^[0-9]$', $product_num))
{
die('Produc number must be a numeric value');
}
if(strlen($product_num)==6)
{
$conn=mysql_pconnect("host", "username", "password");
if(!$conn)
{
die('Could not connect to the database');
}
$result=$mysql_query("select * from dbname where product_number='$product_num'");
if($result==false)
{
die('The product number could not be found');
}
echo"<table>";
echo"<tr>";
echo"<th>Product Number</th><th>Description</th><th>Price</th></tr><tr>";
for($i=1, $i=mysql_num_rows($result), $i++)
{
echo"<th>".$result[$i]."</th>";
}
?>
</tr>
</table>
</body>
</html>
Well i have to leave you here, because i have to go.
Sorry i didnt have time to check the code or run it, but i hope it helps.
I think that what you would also have to do is on the page that i created you would need to create a hidden form (meaning all the inputs would be hidden) that will resent the variables to the page that will process the order and put it in the orders database. Instead of submit button in the form i would put "confirm order" button. The next page however only has to check the availability of the variables, since they have been processed in the prior page.
I'll try to put another post on tomorrow.