How to save inputs of a user in a php form to mysql?

i have written my codes but the data is not getting stored. i cant figure out where is the mistake.. can u guys plz help me with my problem.. i need a solution real quick.. please help me figure out whats wrong with my below mentioned codes.. Here is what i have done.

<?
$con=mysql_connect("localhost","root","");
mysql_select_db("store_records",$con);
@$a=$_POST['p_date'];
@$b=$_POST['d_name'];
@$c=$_POST['m_no'];
@$d=$_POST['email'];
@$e=$_POST['payment'];
@$f=$_POST['address1'];
@$g=$_POST['address2'];
if(@$_POST['info'])
{
echo $query="insert into distributor_records(Payment_Date,Distributor_Name,Mobile_No,Email,Payment,Address1,Address2)values('$a','$b','$c','$d','$e','$f','$g')";
echo "Record Successfully stored in DATABASE";
mysql_query($query);
}
?>
<html>
<head>
</head>
<body bgcolor="#CCCCCC">
<center><h1><u>Distributor Payments</u></h1></center>

<form method="post">
<table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px"
align="center" border="0">
<tr>
<td colspan="4" style="background:#0066FF; color:#FFFFFF; fontsize:
20px" align="center">ADD DISTRIBUTOR RECORD</td></tr>
<tr>
<td>Date:</td>
<td><input type="date" name="p_date"/></td>
<tr>
<td>Name:</td>
<td><input type="text" name="d_name" size="50"></td></tr>
<tr>
<td>Mobile No:</td>
<td><input type="text" name="m_no" size="50"></td></tr>
<tr>
<td>Email: </td>
<td><input type="text" name="email" size="50"></td></tr>
<tr>
<td>Payment:</td>
<td><input type="text" name="payment" size="50"></td></tr>
<tr>
<td>Address1</td>
<td><input type="text" name="address1" size="50"></td></tr>
<tr>
<td>Address2</td>
<td><input type="text" name="address2" size="50"></td></tr>
<tr>
<td colspan="4" align="center">
<input type="submit" name="info" style="font-face: 'Comic Sans MS'; font-  size: larger; color: teal; background-color: #FFFFC0; border: 3pt ridge   lightgrey" value="Add Record"> |
<button type="reset" style="font-face: 'Comic Sans MS'; font-size: larger; color: teal; background-color: #FFFFC0; border: 3pt ridge lightgrey" value="Reset Form">Reset Form</button></td>
</tr>

</table>
</form>
<p align="center"><a href="Distributor Payments.php">Go Back To Main Page</a></p>
</body>
</html>

Answers


Try this:

if($_POST['info'])
{
  $query="insert into distributor_records (Payment_Date,Distributor_Name,Mobile_No,Email,Payment,Address1,Address2)values('".$a."','".$b."','".$c."','".$d."','".$e."','".$f."','".$g."')";

mysql_query($query) or die(mysql_error());

if (mysql_query($query)) {

  echo "Record Successfully stored in DATABASE";

 }  else {
    echo mysql_error();
 }

Hope this helps.

Peace! xD


Need Your Help

make element take up the space of a block, but render as inline

css

Here is an example of what I'm working with. http://jsfiddle.net/5J4PE/

Get original filename when downloading with WebClient

c# .net webclient

Is there any way to know the original name of a file you download using the WebClient when the Uri doesn't contain the name?