can anyone please help me to build a form with validation. I am using the form in a html page and it is processed in another php page. The form has only radio buttons for five options.for example cash.if the required cash is less than the user's cash in the datbase, the form should have a red highlight letters telling that the "cash is not enough" in the same page with form.
Regards!

Have you written any code for this yet? We can help you with what you have but we won't do the work for you. We're here to help, not be free labor. :)

Have you written any code for this yet? We can help you with what you have but we won't do the work for you. We're here to help, not be free labor. :)

form page:
print("<table align=\"left\" width=\"200\" bgcolor=\"#CCCCCC\" border=\"1\" bordercolor=\"#000000\">");
print("<tr>");
print("<td colspan=\"3\"><p align=\"center\">Guns</p></td>");
print("</tr>");
$query="SELECT * FROM guns ";
$con=new Connection();
$con->setQuery($query);
$con->setDatabase('DB_NAME');
$sth=$con->runQuery();
?>
<form name="gunstransaction" action="process.php" method="POST">
<?php
$count=1;
while($row=mysql_fetch_array($sth,MYSQL_NUM)){
print("<tr>");
print("<td>");
?>
<input type="radio" name="guns" value="<?php echo("$count"); ?>"></input>
<?php
$count++;
print("</td>");
print("<td>");
print("$row[1]");
print("</td>");
print("<td>");
print("$");
print("$row[2]");
print("</td>");
}
print("</tr>");
print("<tr>");
print("<td colspan=\"3\">");

?>

<input type="hidden" name="subguns" value="1">
<p align=center><input type="submit" value="Buy !"></p>
</form>


process.php

$guns_id = $_POST;

$query="SELECT * FROM guns WHERE guns_id= '$guns_id'";
$con=new Connection();
$con->setQuery($query);
$con->setDatabase('DB_NAME');
$sth=$con->runQuery();
$row=mysql_fetch_array($sth,MYSQL_ASSOC);
$guns= $row;
$guns_price = $row;
if ($session->usercash <= $guns_price){

//echo("Not Enough Cash or you will have no cash left if this transaction is allowed.");
}
else{
$new_cash = $session->usercash - $guns_price;
$retval = $session->gunstransaction($guns, $new_cash);
header("Location: buy.php");
}
}

Done by myself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.