Fluoresce Posted March 30, 2009 Share Posted March 30, 2009 I have a web form on my site. When someone fills it in, my script checks that everything has been filled in, like this: if ($name == '') { echo "You have not entered your name." } elseif ($website == '') { echo "You have not entered your website." } elseif . . . My form works perfectly well on my own server. There is nothing wrong with the script or markup. However, on HostGator, it always says: "You have not entered your name." The name is the first thing that is checked. My question is, are there any server-side configurations which might be causing this problem? I ask because I initially had another problem, which caused HostGator staff to change things in my folders (I don't know what). I think they might have changed something which is now causing this error. Quote Link to comment https://forums.phpfreaks.com/topic/151811-solved-very-strange-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 30, 2009 Share Posted March 30, 2009 How is your code setting the $name and $website variables from your form data? Quote Link to comment https://forums.phpfreaks.com/topic/151811-solved-very-strange-problem/#findComment-797115 Share on other sites More sharing options...
Fluoresce Posted March 30, 2009 Author Share Posted March 30, 2009 Here's the form: <form method="post" action="submitstore-processor.php"> <table class="center" style="text-align:left" width="628px" border="0" cellpadding="5" cellspacing="5"> <tr> <td colspan="2"><span class="red">*</span> Business name (e.g., My Business, Inc.):</td> </tr> <tr> <td colspan="2"><input type="text" name="adv" size="42" maxlength="32" /></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span class="red">*</span> Full web address (e.g., http://www.MyBusiness.com):</td> </tr> <tr> <td colspan="2"><input type="text" name="website" size="42" maxlength="41" /></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span class="red">*</span> Which category best suits your business?</td> </tr> <tr> <td> <input type="radio" name="catid" value="18" id="handbags" /><label for="handbags">Handbags</label><br /> <input type="radio" name="catid" value="16" id="jewelry" /><label for="jewelry">Jewelry</label><br /> <input type="radio" name="catid" value="7" id="shoes" /><label for="shoes">Shoes</label><br /> <input type="radio" name="catid" value="14" id="mens" /><label for="mens">Men's Apparel</label><br /> <input type="radio" name="catid" value="13" id="womens" /><label for="womens">Women's Apparel</label><br /> <input type="radio" name="catid" value="6" id="childs" /><label for="childs">Children's Apparel</label><br /> <input type="radio" name="catid" value="8" id="appmalls" /><label for="appmalls">Apparel Malls</label><br /> <input type="radio" name="catid" value="2" id="aut" /><label for="aut">Auto Parts and Accessories</label><br /> <input type="radio" name="catid" value="28" id="autosup" /><label for="autosup">Autobody Supplies</label><br /> <input type="radio" name="catid" value="3" id="babygear" /><label for="babygear">Baby Gear</label><br /> <input type="radio" name="catid" value="4" id="books" /><label for="books">Books</label><br /> <input type="radio" name="catid" value="5" id="coelec" /><label for="coelec">Consumer Electronics</label><br /> <input type="radio" name="catid" value="25" id="supp" /><label for="supp">Computer/Tech Support</label><br /> <input type="radio" name="catid" value="20" id="peri" /><label for="peri">Electronic Peripherals</label><br /> <input type="radio" name="catid" value="12" id="cosmetics" /><label for="cosmetics">Cosmetics</label><br /> </td> <td> <input type="radio" name="catid" value="29" id="bathbod" /><label for="bathbod">Bath and Body</label><br /> <input type="radio" name="catid" value="21" id="fragrance" /><label for="fragrance">Fragrance</label><br /> <input type="radio" name="catid" value="22" id="wellness" /><label for="wellness">Wellness</label><br /> <input type="radio" name="catid" value="9" id="furnit" /><label for="furnit">Furniture and Decor</label><br /> <input type="radio" name="catid" value="23" id="kitchen" /><label for="kitchen">Kitchen</label><br /> <input type="radio" name="catid" value="30" id="bedbath" /><label for="bedbath">Bed and Bath</label><br /> <input type="radio" name="catid" value="27" id="garden" /><label for="garden">Garden</label><br /> <input type="radio" name="catid" value="15" id="pets" /><label for="pets">Pets</label><br /> <input type="radio" name="catid" value="26" id="music" /><label for="music">Music</label><br /> <input type="radio" name="catid" value="10" id="movies" /><label for="movies">Movies</label><br /> <input type="radio" name="catid" value="11" id="virtmalls" /><label for="virtmalls">Virtual Malls</label><br /> <input type="radio" name="catid" value="24" id="exerc" /><label for="exerc">Exercise and Health</label><br /> <input type="radio" name="catid" value="19" id="sports" /><label for="sports">Sports Equipment</label><br /> <input type="radio" name="catid" value="17" id="voip" /><label for="voip">VoIP</label><br /> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span class="red">*</span> What types of products/services do you offer? Please be specific.</td> </tr> <tr> <td colspan="2"> <textarea name="prod_serv" id="prod_serv" cols="72" rows="3" onkeydown="textCounter(document.getElementById('prod_serv'), document.getElementById('remLen1'), 255)" onkeyup="textCounter(document.getElementById('prod_serv'), document.getElementById('remLen1'), 255)"> </textarea> <br /> <input readonly="readonly" type="text" id="remLen1" size="3" maxlength="3" value="255" /> characters left </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span class="red">*</span> What is your return policy? Possible answers include: N/A, none, 60-day return or exchange guarantee, etc.</td> </tr> <tr> <td colspan="2"> <textarea name="returns" id="returns" cols="72" rows="3" onkeydown="textCounter(document.getElementById('returns'), document.getElementById('remLen2'), 200)" onkeyup="textCounter(document.getElementById('returns'), document.getElementById('remLen2'), 200)"> </textarea> <br /> <input readonly="readonly" type="text" id="remLen2" size="3" maxlength="3" value="200" /> characters left </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span class="red">*</span> Benefits and features. Do you offer additional guarantees, policies, programs, resources, features or services which may be of benefit to customers? Possible answers include: N/A, none, free U.S. deliveries, rewards program, lowest price guarantee, price match policy, gift cards, product reviews, size charts, informative articles, product buying guides, glossaries, community forums, custom orders, shopping assistants, on-site videos, free samples with orders, etc.</td> </tr> <tr> <td colspan="2"> <textarea name="benefits" id="benefits" cols="72" rows="3" onkeydown="textCounter(document.getElementById('benefits'), document.getElementById('remLen3'), 255)" onkeyup="textCounter(document.getElementById('benefits'), document.getElementById('remLen3'), 255)"> </textarea> <br /> <input readonly="readonly" type="text" id="remLen3" size="3" maxlength="3" value="255" /> characters left </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span class="red">*</span> How do you provide customer support? Possible answers include: phone, toll-free phone, live chat, e-mail, support forum, online remote access, etc.</td> </tr> <tr> <td colspan="2"> <textarea name="xsupport" id="xsupport" cols="72" rows="3" onkeydown="textCounter(document.getElementById('xsupport'), document.getElementById('remLen4'), 60)" onkeyup="textCounter(document.getElementById('xsupport'), document.getElementById('remLen4'), 60)"> </textarea> <br /> <input readonly="readonly" type="text" id="remLen4" size="3" maxlength="3" value="60" /> characters left </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span class="red">*</span> What payment methods do you accept? Possible answers include: MasterCard, Visa, American Express, Discover, debit cards with MasterCard and Visa logos, PayPal, check, cashier's check, wire transfer, money order, Bill Me Later, etc.</td> </tr> <tr> <td colspan="2"> <textarea name="payment" id="payment" cols="72" rows="3" onkeydown="textCounter(document.getElementById('payment'), document.getElementById('remLen5'), 150)" onkeyup="textCounter(document.getElementById('payment'), document.getElementById('remLen5'), 150)"> </textarea> <br /> <input readonly="readonly" type="text" id="remLen5" size="3" maxlength="3" value="150" /> characters left </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span class="red">*</span> Customers from which U.S. states are subject to sales tax? Possible answers include: N/A, none, applicable to customers within California, etc.</td> </tr> <tr> <td colspan="2"> <textarea name="tax" id="tax" cols="72" rows="3" onkeydown="textCounter(document.getElementById('tax'), document.getElementById('remLen6'), 100)" onkeyup="textCounter(document.getElementById('tax'), document.getElementById('remLen6'), 100)"> </textarea> <br /> <input readonly="readonly" type="text" id="remLen6" size="3" maxlength="3" value="100" /> characters left </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span class="red">*</span> What delivery options do you provide for U.S. customers? Please be specific, including delivery times were possible. Possible answers include: N/A, USPS Priority Mail (1-2 days, not including Saturdays), USPS Express Mail (overnight, 365 days a year), UPS Ground (1-5 business days), UPS Next Day Air (next business day), FedEx Home Delivery (1-5 business days), FedEx 2Day (2 business days), etc.</td> </tr> <tr> <td colspan="2"> <textarea name="usdelopt" id="usdelopt" cols="72" rows="3" onkeydown="textCounter(document.getElementById('usdelopt'), document.getElementById('remLen7'), 170)" onkeyup="textCounter(document.getElementById('usdelopt'), document.getElementById('remLen7'), 170)"> </textarea> <br /> <input readonly="readonly" type="text" id="remLen7" size="3" maxlength="3" value="170" /> characters left </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span class="red">*</span> Do you deliver to international locations? Or, are your services available to people in other countries? If so, please specify. Possible answers include: U.S. only, world-wide, etc.</td> </tr> <tr> <td colspan="2"> <textarea name="intdel_avail" id="intdel_avail" cols="72" rows="3" onkeydown="textCounter(document.getElementById('intdel_avail'), document.getElementById('remLen8'), 80)" onkeyup="textCounter(document.getElementById('intdel_avail'), document.getElementById('remLen8'), 80)"> </textarea> <br /> <input readonly="readonly" type="text" id="remLen8" size="3" maxlength="3" value="80" /> characters left </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span class="red">*</span> Do you provide a facility for order status tracking?</td> </tr> <tr> <td colspan="2"> <input type="radio" name="ordertrack" id="yes" value="available" /> <label for="yes">Yes</label><br /> <input type="radio" name="ordertrack" id="no" value="unavailable" /> <label for="no">No</label><br /> <input type="radio" name="ordertrack" id="na" value="N/A" /> <label for="na">N/A</label> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2">(Optional) Please now describe your business. Explain anything that we might have missed, or elaborate on answers that you gave above.</td> </tr> <tr> <td colspan="2"> <textarea name="description" id="description" cols="72" rows="3" onkeydown="textCounter(document.getElementById('description'), document.getElementById('remLen9'), 5000)" onkeyup="textCounter(document.getElementById('description'), document.getElementById('remLen9'), 5000)"> </textarea> <br /> <input readonly="readonly" type="text" id="remLen9" size="3" maxlength="3" value="5000" /> characters left </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><input type="submit" name="send" value="Submit" /></td> </tr> </table> </form> Here's submitstore.php: <?php // Required fields. Function mysql_real_escape_string() escapes // all disallowed characters (e.g., apostrophes) in the SQL statement. $adv = mysql_real_escape_string($_POST['adv']); $website = $_POST['website']; $catid = $_POST['catid']; $prod_serv = mysql_real_escape_string($_POST['prod_serv']); $returns = mysql_real_escape_string($_POST['returns']); $benefits = mysql_real_escape_string($_POST['benefits']); $support = mysql_real_escape_string($_POST['xsupport']); $payment = mysql_real_escape_string($_POST['payment']); $tax = mysql_real_escape_string($_POST['tax']); $usdelopt = mysql_real_escape_string($_POST['usdelopt']); $intdel_avail = mysql_real_escape_string($_POST['intdel_avail']); $ordertrack = $_POST['ordertrack']; // Optional field $description = mysql_real_escape_string($_POST['description']); // As $description can be NULL, prepare it for the insert. if (!$description) { $description = "NULL"; } else { $description = "'$description'"; } // Check that the required fields have been filled in. if ($adv == '') { echo "<p>You have not entered your business's name. Please go back and try again.</p>"; } elseif ($website == '') { echo "<p>You have not entered your web address. Please go back and try again.</p>"; } elseif ($catid == '') { echo "<p>You have not selected the category which best suits your business. Please go back and try again.</p>"; } elseif ($prod_serv == '') { echo "<p>You have not specified the types of products/services you offer. Please go back and try again.</p>"; } elseif ($returns == '') { echo "<p>You have not specified a return policy. Please go back and try again.</p>"; } elseif ($benefits == '') { echo "<p>You have not entered anything in the Benefits and Features field. Please go back and try again.</p>"; } elseif ($support == '') { echo "<p>You have not specified how you provide customer support. Please go back and try again.</p>"; } elseif ($payment == '') { echo "<p>You have not specified what payment methods you accept. Please go back and try again.</p>"; } elseif ($tax == '') { echo "<p>You have not entered anything in the Sales Tax field. Please go back and try again.</p>"; } elseif ($usdelopt == '') { echo "<p>You have not specified which delivery options you provide for U.S. customers. Please go back and try again.</p>"; } elseif ($intdel_avail == '') { echo "<p>You have not specified the geographic availability of your products/services. Please go back and try again.</p>"; } elseif ($ordertrack == '') { echo "<p>You have not specified if you provide a facility for order status tracking. Please go back and try again.</p>"; } else { // Generate entry for advdate. $advdate = date("Y-m-d"); // Insert the column entries that you've got so far. $conn = mysql_connect('localhost', 'heru_tehutimaat', 'atumra') or die(mysql_error()); mysql_select_db('heru_ctyi', $conn) or die(mysql_error()); $insert = mysql_query("INSERT INTO tadv (visitaffurl, adv, catid, advdate, website, prod_serv, returns, benefits, support, payment, tax, usdelopt, intdel_avail, ordertrack, description) VALUES ('$website', '$adv', '$catid', '$advdate', '$website', '$prod_serv', '$returns', '$benefits', '$support', '$payment', '$tax', '$usdelopt', '$intdel_avail', '$ordertrack', $description)") or die(mysql_error()); // Get the inserted row's advid. $advid = mysql_insert_id(); // If the insert worked, generate the remaining // column entries, then update the row. if ($insert) { $update = "UPDATE tadv SET store = 'store.php?storeid=$advid', visit = 'visit.php?siteid=$advid' WHERE advid = $advid"; $updated = mysql_query($update, $conn) or die(mysql_error()); // If the update worked, present a message. if ($updated) { echo "<p>Success! Thank you for your submission.</p>"; } else { echo "<p>Sorry! An error occurred. Please go back and try again.</p>"; } } } ?> Can you see anything wrong? Why does it work on my server but not on HostGator? Quote Link to comment https://forums.phpfreaks.com/topic/151811-solved-very-strange-problem/#findComment-797140 Share on other sites More sharing options...
PFMaBiSmAd Posted March 30, 2009 Share Posted March 30, 2009 The form and the php code you just posted has nothing to do with the first post in this thread. There is no 'name' field in the form and the code to set or check the $name variable does not exist in the php code. Cannot help you unless accurate information is posted. Quote Link to comment https://forums.phpfreaks.com/topic/151811-solved-very-strange-problem/#findComment-797153 Share on other sites More sharing options...
Fluoresce Posted March 30, 2009 Author Share Posted March 30, 2009 The form and the php code you just posted has nothing to do with the first post in this thread. There is no 'name' field in the form and the code to set or check the $name variable does not exist in the php code. Cannot help you unless accurate information is posted. "Name" was just a simplification. Its equivalent is adv (short for advertiser). Quote Link to comment https://forums.phpfreaks.com/topic/151811-solved-very-strange-problem/#findComment-797159 Share on other sites More sharing options...
Fluoresce Posted March 30, 2009 Author Share Posted March 30, 2009 After speaking to another HostGator operator, I am being told that the coding is wrong for their servers. Can you guys see anything wrong? Quote Link to comment https://forums.phpfreaks.com/topic/151811-solved-very-strange-problem/#findComment-797181 Share on other sites More sharing options...
PFMaBiSmAd Posted March 30, 2009 Share Posted March 30, 2009 The posted code is using mysql_real_escape_string() before the mysql_connect() statement, so it would not work except if a system already had a valid mysql connection. Add the following two lines immediately after your first opening <?php tag - ini_set ("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/151811-solved-very-strange-problem/#findComment-797205 Share on other sites More sharing options...
Fluoresce Posted March 30, 2009 Author Share Posted March 30, 2009 PFMaBiSmAd, I thank you for your help. You were right: mysql_real_escape_string() being used before mysql_connect() is what was causing the problem. First, I tried that snippet of code that you gave. It showed loads of errors and warnings. Then, all I done was delete that snippet of code and move the connection to the top of my script, and the problem was fixed. Thank you very much! Quote Link to comment https://forums.phpfreaks.com/topic/151811-solved-very-strange-problem/#findComment-797250 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.