Jump to content

Recommended Posts

Ok i my form is on my local host atm and i feel it all in, goes in to the database and i was happy, untill i tried to enter more then 1 :P i get this message Error: Duplicate entry '0' for key 1, at the stage sat on google for about an hour reading arround and still couldnt find my answer. can anyone help me why i can only insert only 1 row.

 

i manualy put 1 row in by phpmyadmin and then the form inserted one under that, my id number for first row i inserted is 1 and the one which i sent in via form = 0 if that helps.

 

 

That is the code + the connection is in there to just didnt c+p it

 

  <html>
<head> </heaD>
<body>

<form name="form1" method="post" action="">
  <table width="418" align="left" cellpadding="0" cellspacing="0">
    <tr>
      <td width="157"> Name:</td>
      <td width="259"><label for="name"></label>
      <input type="text" name="name" id="name"></td>
    </tr>
    <tr>
      <td>Email:</td>
      <td><label for="email"></label>
      <input type="text" name="email" id="email"></td>
    </tr>
    <tr>
      <td>WiFi Business Name:</td>
      <td><label for="buissnes_name"></label>
      <input type="text" name="buissnes_name" id="buissnes_name_name"></td>
    </tr>
    <tr>
      <td>WiFi Location;</td>
      <td><label for="textfield"></label>
      <input type="text" name="location" id="location"></td>
    </tr>
    <tr>
      <td>Free or Paid:</td>
      <td><input type="radio" name="radio" id="radio" value="radio">
      <label for="radio"></label>
      <input type="radio" name="radio2" id="radio2" value="radio2">
      <label for="radio2"></label></td>
    </tr>
    <tr>
      <td> </td>
      <td><label for="button"></label>
      <input type="submit" name="button" id="button" value="Submit">
      <label for="button2"></label>
      <input type="reset" name="button2" id="button2" value="Reset">       
      <label for="sub"></label></td>
    </tr>
  </table>
</form>

<?php

$sql="INSERT INTO tblbasicform (name, email, buissnes_name, location, free, paid)
VALUES
('$_POST[name]','$_POST[email]','$_POST[buissnes_name]','$_POST[location]','$_POST[free]','$_POST[paid]')";

if (!mysql_query($sql,$connect))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($connect)

?>

</body>
</html>  

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.