Jump to content

[SOLVED] Got everything to work except when I submit it adds blank values to db


prcollin

Recommended Posts

OK.  I have one primary key called Client_id, that is set to autoincrement.  Every time I click submit it does what it is supposed to. But the problem I am having is that all the vales after client_id come in as their default and not the values that I enter into the form.  Here is the form code, the php code and a picture of the database set up.

 

<html>
<body bgcolor="#F0F8FF">

<title> Green Cuts Landscaping - New Client Registration</title>
<font color="darkgreen"><h1><center>Green Cuts Landscaping</h1></head></font>
<h3> <center><font color="green"> New Client Registration</center></h3></font>

<form action="newclient.php">
<table width="500" border="1" align="center">

<tr>
  <td align="right"><b>First Name</td>
  <td align="left"><input type="text" name="client_fname"></td>

  <td align="right"><b>Last Name</td>
  <td align="left"><input type="text" name="client_lname"></td>
</tr>
<tr>
  <td align="right"><b>Address</td>
  <td align="left"><input type="text" name="client_address"></td>

  <td align="right"><b>City</td>
  <td align="left"><input type="text" name="client_city"></td>
</tr>
<tr>
  <td align="right"><b>State</td>
  <td align="left"><input type="text" name="client_state"></td>

  <td align="right"><b>Zip Code</td>
  <td align="left"><input type="text" name="client_zipcode"></td>
</tr>
<tr>
  <td align="right"><b>Phone</td>
  <td align="left"><input type="text" name="client_phone"></td>

  <td align="right"><b>Cell Phone</td>
  <td align="left"><input type="text" name="client_cPhone"></td>
</tr>
<tr>
  <td align="right"><b>Email</td>
  <td align="left"><input type="text" name="client_email"></td>

  <td align="right"><b>Website</td>
  <td align="left"><input type="text" name="client_website"></td>
</tr>
<tr>
  <td align="right"><b>Notes</td>
  <td align="left"><input type="textarea" cols="30" rows="15" name="client_notes"><br><right>
</td>
</tr>
<tr><td></td><td></td>
<td align="center" border="0" padding="0"><input type="submit" name="submit" value="Create Client"></td>
</tr>

</table>

</form>



</body>
</html>

 

heres the php code

 

<?php

include "clientconnect.php";
include "newclient.html";

mysql_select_db('greencut_customercenter', $con);

$client_fname = mysql_real_escape_string($_POST['client_fname']);
$client_lname = mysql_real_escape_string($_POST['client_lname']);
$client_address = mysql_real_escape_string($_POST['client_address']);
$client_city = mysql_real_escape_string($_POST['client_city']);
$client_state = mysql_real_escape_string($_POST['client_state']);
$client_zipcode = mysql_real_escape_string($_POST['client_zipcode']);
$client_phone = mysql_real_escape_string($_POST['client_phone']);
$client_cphone = mysql_real_escape_string($_POST['client_cphone']);
$client_email = mysql_real_escape_string($_POST['client_email']);
$client_website = mysql_real_escape_string($_POST['client_website']);
$client_notes = mysql_real_escape_string($_POST['client_notes']);

$sql="INSERT INTO clients (client_fname, client_lname, client_address, client_city, client_state, client_zipcode, client_phone, client_cphone, client_email, client_website, client_notes) VALUES('$client_fname','$client_lname','$client_address','$client_city','$client_state','$client_zipcode','$client_phone','$client_cphone','$client_email','$client_website','$client_notes')";


if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Client Sucessfully Added To Database";
mysql_close($con);
?>



 

and here is a picture of hte database

 

database.jpg

 

 

any help on why the info i put in form wont post to db would be helpful

I think you need quotes on your field names:

 

$sql="INSERT INTO clients ('client_fname', 'client_lname', 'client_address', 'client_city', 'client_state', 'client_zipcode', 'client_phone', 'client_cphone', 'client_email', 'client_website', 'client_notes') VALUES('$client_fname','$client_lname','$client_address','$client_city','$client_state','$client_zipcode','$client_phone','$client_cphone','$client_email','$client_website','$client_notes')";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.