njmorgan Posted November 20, 2006 Share Posted November 20, 2006 I am trying to send contact information from a website to a sql database. All the code that I have here has worked for the past 6 months and all of a sudden, nothing gets passed but blank fields to the database. I also had some other coding errors that were already cleaned up. I'm thinking there was some sort of PHP or Server update that could have caused this. Could someone just make sure that there isn't something that might need touched up for it to work again. Thanks! Quote Link to comment Share on other sites More sharing options...
njmorgan Posted November 20, 2006 Author Share Posted November 20, 2006 I'll post the file in a second. Quote Link to comment Share on other sites More sharing options...
njmorgan Posted November 20, 2006 Author Share Posted November 20, 2006 <?php if($submit) { $db=mysql_connect ("localhost", "hfarmour_test", "test") or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db("hfarmour_students",$db); $sql = "INSERT INTO Students (fname, lname, address, city, state, zip, PhoneNum, email, contact) VALUES ('$fname', '$lname', '$address','$city','$state', '$zip', '$PhoneNum', '$email', '$contact')";$result = mysql_query($sql); echo "Thank you! Information entered. We will be contacting you shortly."; } else { ?> Quote Link to comment Share on other sites More sharing options...
njmorgan Posted November 20, 2006 Author Share Posted November 20, 2006 <p>Please enter your personal information if you would like to be contacted with further information: </p> <FORM method="post" action="input.php"> <table width="100%" border="0" cellspacing="1"> <tr> <td width="35%">Name: </td> <td width="65%"><input type="text" name="fname" size="25" maxlength="25" value="first name" /> <input type="text" name="lname" size="25" maxlength="25" value="last name" /></td> </tr> <tr> <td>Addresss: </td> <td><input type="text" name="address" size="50" maxlength="50" /></td> </tr> <tr> <td>City:</td> <td><input type="text" name="city" size="25" maxlength="50" /></td> </tr> <tr> <td>State/Province:</td> <td><input type="text" name="state" size="15" maxlength="20" /></td> </tr> <tr> <td>Zip: </td> <td><input type="text" name="zip" size="10" maxlength="10" /></td> </tr> <tr> <td>Phone Number: </td> <td><input type="text" name="PhoneNum" size="12" maxlength="12" /></td> </tr> <tr> <td>Email Address: </td> <td><input type="text" name="email" size="25" maxlength="50" /></td> </tr> <tr> <td>Preferred Way of Contact: </td> <td><label> <input type="radio" name="contact" value="Telephone" />Telephone</label></td> </tr> <tr> <td> </td> <td><label> <input type="radio" name="contact" value="Mail" />Mail</label></td> </tr> <tr> <td> </td> <td><label> <input type="radio" name="contact" value="Email" />Email</label></td> </tr></table> <center> <input name="submit" type="Submit" value="Enter information"> <input name="reset" type="reset" value="Reset Form"> </center> </FORM> <? } ?> Quote Link to comment Share on other sites More sharing options...
njmorgan Posted November 20, 2006 Author Share Posted November 20, 2006 FILE INPUT.PHP<?php session_start();require_once('common.php');$sql = "INSERT INTO Students (fname, lname, address, city, state, zip, PhoneNum, email, contact) VALUES ('$fname', '$lname', '$address','$city','$state', '$zip', '$PhoneNum', '$email', '$contact')";$result = mysql_query($sql); echo "Thank you! Information entered. We will be contacting you shortly."; ?> <HTML></HTML> Quote Link to comment Share on other sites More sharing options...
btherl Posted November 20, 2006 Share Posted November 20, 2006 It looks like register_globals may have been switched off on your server. Instead of using variables directly, like [code=php:0]$fname[/code], you can use the alternative syntax [code=php:0]$_REQUEST['fname'][/code]. That will work for variables from both POST and GET forms.Like this:[code=php:0]$sql = "INSERT INTO Students (fname, lname, address, city, state, zip, PhoneNum, email, contact) VALUES ('{$_REQUEST['fname']}', '{$_REQUEST['lname']}', ...[/code]You may also need to check [code=php:0]$_REQUEST['submit'][/code] instead of [code=php:0]$submit[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.