can this by made with the normal INSERT INTO .. thing or thoes requere someting alse??
P.S: sorry for the looong post
I don't see why not. What are you actually trying to do though ?ta2shop wrote:can this by made with the normal INSERT INTO .. thing or thoes requere someting alse??
<div id="wrapper">
<div id="top">
Generate a Code!
</div>
<div id="form">
<form action="index.php" method="post">
<table align="center" border="0" cellpadding="2" cellspacing="2">
<tr align="center">
<td>Postal Code</td>
<td>Random Generated Code</td>
</tr>
<tr align="center">
<td><input type="text" name="postal" size="13" class="field" /></td>
<td><input type="text" name="random" size="13" class="field" value="<?php echo $random; ?>" /></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" name="generate" value="Generate" class="btn" /></td>
</tr>
</table>
</form>
</div>
</div>
<div id="lowbox">
<div id="top2">
Serch the Results!
</div>
</div>
i havent made the php part becouse i do not now how rand(0123456789,9876543210);the problem is i dont now how to do it.
<?php $rand = rand(0. 9); // or whichever numbers you want ?> <input type="text" value="<?php echo $rand; ?>" />
INSERT INTO `table` (`post_code`, `random`) VALUES ('{$post_code}', {$rand});
ie, generating the random number in the backend only,
<?php
$connect = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("ta2shop") or die(mysql_error());
// form data
$postal = $_POST['postal'];
$random = 'TA2_'.rand(0123456789,9876543210);
$date = date("Y-m-d");
if(isset($_POST['generate'])) {
if($_POST['postal']) {
$query = mysql_query("INSERT INTO postal_codes VALUES('','$postal','$random','$date')") or die(mysql_error());
echo'<center>Succses, your traker code is: '.$random.' </center>';
}
else {
echo"<center>You must provide a postal code!</center>";
}
}
?>
any sugestions.<input type='text' name='random' value='<?php echo $rand; ?>'
i alreadi did!Carbine wrote:to display it into a input field just do the following:<input type='text' name='random' value='<?php echo $rand; ?>'
<form action="index.php" method="post"> <table align="center" border="0" cellpadding="2" cellspacing="2"> <tr align="center"> <td>Postal Code</td> <td>Random Generated Code</td> </tr> <tr align="center"> <td><input type="text" name="postal" size="13" class="field" /></td> <td><input type="text" name="random" size="13" class="field" value='<?php echo $random; ?>' /></td> </tr> <tr align="center"> <td colspan="2"><input type="submit" name="generate" value="Generate" class="btn" /></td> </tr> </table> </form>and still nothing
'<?php echo $random; ?>'to:
"<?php echo $random; ?>"Sometimes the kind of quotation marks have an effect, that's the only help I can give till a professional comes on and replys
<?php
$connect = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("ta2shop") or die(mysql_error());
// form data
$postal = $_POST['postal'];
$random = 'TA2_'.uniqid(rand(0123456789,9876543210));
$date = date("Y-m-d");
if(isset($_POST['generate'])) {
if($_POST['postal']) {
$query = mysql_query("INSERT INTO postal_codes VALUES('','$postal','$random','$date')") or die(mysql_error());
while($row = mysql_fetch_assoc($query)) {
if($row['postal']!= $postal) {
echo'<center>Succses, your traker code is: '.$random.' </center>';
}
else {
echo $random .'Already in Use';
}
}
}
else {
echo"<center>You must provide a postal code!</center>";
}
}
?>
thanks<?php
$connect = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("ta2shop") or die(mysql_error());
// form data
$postal = $_POST['postal'];
$random = 'TA2_'.uniqid(rand(0123456789,9876543210));
$date = date("Y-m-d");
if (isset($_POST['generate'])) {
if($_POST['postal']) {
$check = mysql_query("SELECT * FROM postal_codes WHERE '$postal'=postal");
$numrows = mysql_num_rows($check);
if ($numrows>=1)
die("Postal code has already been used");
else {
$query = mysql_query("INSERT INTO postal_codes VALUES('','$postal','$random','$date')") or die(mysql_error());
echo "<center>Success, your tracker ID is:".$random."</center>";
}
}
else echo "<center>You must provide a postal code!</center>";
}
?> $query = mysql_query("INSERT INTO postal_codes VALUES('','$postal','$random','$date')") or die(mysql_error());
while($row = mysql_fetch_assoc($query)) {
if($row['postal']!= $postal) {
echo'<center>Succses, your traker code is: '.$random.' </center>';
}
else {
echo $random .'Already in Use';
}
}
this is wrong, an INSERT query does not work in the same way as a SELECT, ie you cannot fetch its result.