Jump to content

somo

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by somo

  1. the problem lies in the  if statement "<?php   if ($_POST['submit']) " php just doesn't like it wherever its placed.  had the original code working a while back and come back to it and an extra record set is being added and shouldn't i have got client side form validation but that ISN'T the issue. This is doing my head in  >:( [quote author=Crayon Violent link=topic=99191.msg390581#msg390581 date=1151862097] the format should be like this: [code] <?php   if ($_POST['submit']) {     //do the insert stuff here   } else {     //display the form     //in the form be sure to name your submit button 'submit'    } ?> [/code] this is to make it work. I will agree that you should sanitize your user's input etc.. but that's not the question here. [/quote]
  2. Still getting undefined index error as you have shown in the code below. [quote author=avo link=topic=99191.msg390546#msg390546 date=1151859467] HI where are you putting you if statement is it [quote] if ($_POST['submit']) { $link = mysql_connect('localhost', 'root', ''); if (! $link) die("Could not connect to MySQL"); mysql_select_db($db , $link) or die("Could not select the database: ".mysql_error()); mysql_query("INSERT INTO customer (C_Title, C_Firstname, C_Surname, C_Address1, C_Address2, C_Address3, C_TownCity, C_County, C_PostCode, C_Telephone, C_Email, C_Username, C_Password) VALUES ('$C_Title', '$C_Firstname', '$C_Surname', '$C_Address1', '$C_Address2', '$C_Address3', '$C_TownCity', '$C_County', '$C_PostCode', '$C_Telephone', '$C_Email', '$C_Username', '$C_Password')")or die("Error Inserting Customer Details: ".mysql_error()); mysql_close($link); } [/quote] [/quote]
  3. [quote author=redarrow link=topic=99191.msg390535#msg390535 date=1151858658] if($_POST['submit']){ } sorry a sleep. [/quote] [color=red]Another error: Notice: Undefined index: submit[/color]
  4. [quote author=redarrow link=topic=99191.msg390525#msg390525 date=1151857629] have a go. if($_POST(['submit'])) { insert code } [/quote] [color=red]Now there is a parse error Parse error: parse error, expecting `')'' [/color]
  5. [quote author=redarrow link=topic=99191.msg390493#msg390493 date=1151852108] what varable name is not entering to the database fromthe insert properly [color=red]The information is added to MYSQL fine the problem is there is an additional empty record set added at the same time. so fo example customer id #1 will have the data entered BUT... customer ID #2 there are just empty fields [/color] [color=red]DONE[/color] double quotes missing on all inputs example correct way ok. < input type="text" name="fname" > select box correct way <select name=" " > <option value=" "> whaterver </option> </select> before database entrys stripslashes example only. [color=red]DONE[/color] $C_Firstname=stripslashes($_POST['fname']); form valadation needed. email valadation needed. check for existing username and password if exist echo message nedded. loots more good luck. [/quote]
  6. I have created a php script that adds customers to a MySQL database but when the form is filled out and the data is posted to MySQL, i get the information entered in the fields sent to the database all in the correct way but i also get an empty record set. Does any one know why this is happening? Is it the script not excuting correctly or an issue with MYSQL? All help is appreciated (the code is below) HTML FORM <form name="formcheck" onsubmit="return formCheck(this);" action="insert_record.php" method="POST">   <table>       <tr>         <td></td>         <td>Please supply information about the customer in the fields below</td>       </tr>       <tr>         <td>Title</td>         <form>         <td><select name=title>         <option value=Mr>Mr         <option value=Ms>Ms         <option value=Miss>Miss         <option value=Mrs>Mrs</td>         </select>         </form>       </tr>   <tr>         <td>Firstname</td>         <td><input type=text name=fname size=30 /></td>       </tr>       <tr>         <td>Surname</td>         <td><input type=text name=sname size=30 /></td>       </tr>       <tr>         <td>Address #1</td>         <td><input type=text name=add1 size=50 /></td       </tr>             <tr>         <td>Address #2</td>         <td><input type=text name=add2 size=50 /></td>       </tr>       <tr>         <td>Address #3</td>         <td><input type=text name=add3 size=50 /></td>       </tr>       <tr>         <td>Town/City</td>         <td><input type=text name=town size=40 /></td>       </tr>       <tr>         <td>County</td>         <td><input type=text name=county size=40 /></td>       </tr>       <tr>         <td>Post Code</td>         <td><input type=number name=pcode size=7 /></td>       </tr>             <tr>         <td>Telephone (Please include area code)</td>         <td><input type=number name=tel size=11 /></td>       </tr>                     <td>E-mail</td>         <td><input type=text name=email size=50 /></td>       </tr>                     <td>Username</td>         <td><input type=text name=username size=30 /></td>       </tr>               <td>Password</td>         <td><input type=password name=pass size=30 /></td>       </tr>       <tr> <td><input type=submit value=Submit></td> <td><input type=reset></td> </tr> </form> </td></tr></table> SCRIPT TO ADD ENTERD DATA TO DATABASE <? $C_Title=$_POST['title']; $C_Firstname=$_POST['fname']; $C_Surname=$_POST['sname']; $C_Address1=$_POST['add1']; $C_Address2=$_POST['add2']; $C_Address3=$_POST['add3']; $C_TownCity=$_POST['town']; $C_County=$_POST['county']; $C_PostCode=$_POST['pcode']; $C_Telephone=$_POST['tel']; $C_Email=$_POST['email']; $C_Username=$_POST['username']; $C_Password=$_POST['pass']; print($C_Title); print($C_Firstname); print($C_Surname); print($C_Address1); print($C_Address2); print($C_Address3); print($C_TownCity); print($C_County); print($C_PostCode); print($C_Telephone); print($C_Email); print($C_Username); print($C_Password); $db="hotelBooking"; $link = mysql_connect('localhost', 'root', ''); if (! $link) die("Could not connect to MySQL"); mysql_select_db($db , $link) or die("Could not select the database: ".mysql_error()); mysql_query("INSERT INTO customer (C_Title, C_Firstname, C_Surname, C_Address1, C_Address2, C_Address3, C_TownCity, C_County, C_PostCode, C_Telephone, C_Email, C_Username, C_Password) VALUES ('$C_Title', '$C_Firstname', '$C_Surname', '$C_Address1', '$C_Address2', '$C_Address3', '$C_TownCity', '$C_County', '$C_PostCode', '$C_Telephone', '$C_Email', '$C_Username', '$C_Password')")or die("Error Inserting Customer Details: ".mysql_error()); mysql_close($link); print "New Customer Record Added Sucessfully"; ?>
×
×
  • 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.