ethan6 Posted February 2, 2010 Share Posted February 2, 2010 Ok, so i have a very simple PHP contact form for submitting info on my website http://itronicsrepair.com/contact.php However, when you click submit, it doesn't actually submit the data. I had this exact same form on my last hosting server, but when i put it on here, it no longer works. I have double checked that I have included all the includes, etc. Here is the code: <?php include("configure_contact.php"); if (isset($_POST['submit'])) { echo $msg; if (!$pass) { if (!isset($email)) echo "Error, please re-send $fname" ; $todayis = date("l, F j, Y, g:i a") ; $message ="$todayis [EST] \n"; $message .="First Name: $fname \n"; $message .="Last Name: $lname \n"; $message .="Address1: $address1 \n"; $message .="Address2: $address2 \n"; $message .="City: $city \n"; $message .="State: $state \n"; $message .="Zip Code: $zip \n"; $message .="Email: $sendemail \n"; $message .="Phone: $phone \n"; $message .="iPod Generation: $gen \n"; $message .="Comments: $comments \n"; $from = "From: $sendemail\r\n"; if ($email != "") mail($email, $subject, $message, $from); ?> <table width="80% align="center"> <tr> <td> <center><img src="img/tick.jpg"></center> <b><p align="center"> Date Sent: <?php echo $todayis ?> <br> Sent By: <?php echo $fname ?> ( <?php echo $sendemail ?> ) <br> <br>Thank you, your comment has been submitted. <br> <a href="index.php"> Return to Main Page </a> </td> </tr> </table> <?php exit();}} ?> <link href="style.txt" rel="stylesheet" type="text/css"> <table width="80%" border="0" cellpadding="5"> <tr> <th align="left" valign="top" scope="col"> <p align="left" class="stdtxtlocate"><h4></h4> </th> </tr> <tr> <th align="left" valign="top" scope="col"> <form action="" method="post"> <table width="80%" border="0" cellpadding="5"> <tr> <?php if ($fnameq == true) { ?><td><div align="left">First Name</div><br><input name="fname" type="text" size="25" maxlength="40" value="<?php echo $_POST['fname']; ?>" class="<?php echo $style1; ?>"> </td><?php } ?> <?php if ($lnameq == true) { ?><td><div align="left">Last Name</div><br><input name="lname" type="text" size="25" maxlength="40" value="<?php echo $_POST['lname']; ?>" class="<?php echo $style2; ?>"> </td><?php } ?> </tr> <tr> <?php if ($address1q == true) { ?><td><div align="left">Address 1</div><br><input name="address1" type="text" size="25" maxlength="40" value="<?php echo $_POST['address1']; ?>" class="<?php echo $style3; ?>"> </td><?php } ?> <?php if ($address2q == true) { ?><td><div align="left">Address 2</div><br><input name="address2" type="text" size="25" maxlength="40" value="<?php echo $_POST['address2']; ?>" class="<?php echo $style4; ?>"> </td><?php } ?> </tr> <tr> <?php if ($cityq == true) { ?><td><div align="left">City</div><br><input name="city" type="text" size="25" maxlength="40" value="<?php echo $_POST['city']; ?>" class="<?php echo $style5; ?>"> </td><?php } ?> <?php if ($stateq == true) { ?><td><div align="left">State</div><br><input name="state" type="text" size="25" maxlength="40" value="<?php echo $_POST['state']; ?>" class="<?php echo $style6; ?>"> </td><?php } ?> </tr> <tr> <?php if ($zipq == true) { ?><td><div align="left">Zip Code</div><br><input name="zip" type="text" size="25" maxlength="40" value="<?php echo $_POST['zip']; ?>" class="<?php echo $style7; ?>"> </td><?php } ?> <?php if ($sendemailq == true) { ?><td><div align="left">Email</div><br><input name="sendemail" type="text" size="25" maxlength="40" value="<?php echo $_POST['sendemail']; ?>" class="<?php echo $style8; ?>"> </td><?php } ?> </tr> <tr> <?php if ($phoneq == true) { ?><td><div align="left">Phone</div><br><input name="phone" type="text" size="25" maxlength="40" value="<?php echo $_POST['phone']; ?>" class="<?php echo $style9; ?>"> </td><?php } ?> <?php if ($genq == true) { ?><td><div align="left">iPod Generation</div><br><input name="gen" type="text" size="25" maxlength="40" value="<?php echo $_POST['gen']; ?>" class="<?php echo $style10; ?>"> </td><?php } ?> </tr> <tr> <?php if ($commentsq == true) { ?><td><div align="left">Comments</div><br><textarea name="comments" rows="10" cols="35" class="<?php echo $style11; ?>"><?php echo $_POST['comments']; ?></textarea> </td><?php } ?> </tr> <tr> <td><b>Email MUST be valid for a reply.</b><br><input type="submit" name="submit" value="Submit Comments"></td> <td> </td> </tr> </table> </form> </th> </tr> </table> Thank you for any help! ps. all of my forms on my site stopped submitting the info after i moved servers. Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/ Share on other sites More sharing options...
aeroswat Posted February 2, 2010 Share Posted February 2, 2010 I don't see anywhere that you are setting variables equal to your POST array variables Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/#findComment-1005618 Share on other sites More sharing options...
mikesta707 Posted February 2, 2010 Share Posted February 2, 2010 Aeroswat has probably pin pointed your problem. What version of PHP did your old and new server have? If you had an older version, the setting register_globals was probably set on, which would make the code work. This setting has been deprecated as of php 5, removed as of 6. http://php.net/manual/en/ini.core.php (search for the register_globals entry for more info) Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/#findComment-1005627 Share on other sites More sharing options...
wildteen88 Posted February 2, 2010 Share Posted February 2, 2010 Your code replies on a setting called register_globals to be enabled in order for it to work properly, your new server most probably has this setting disabled. register_globals has been disabled since the release of PHP4.2 (which was released way back in 2002). Basically all you need to do is, instead of using the variable $name_of_from_field to grab the value from one of your form fields, you'd instead use the $_POST superglobal, eg $_POST['msg'] to get the value from the form field named as msg, for the form field named as email you'd use $_POST['email'] Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/#findComment-1005628 Share on other sites More sharing options...
ethan6 Posted February 2, 2010 Author Share Posted February 2, 2010 yes that would make sense. I also played around with my code a bit and found out this: when I have this code at the top of the page, it doesn't work, but if i delete it, it does work: <?php // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions require_once('inc/functions.inc.php'); // Start the session session_start(); ?> any ideas why that would be? I'm guessing something with the session_start() is screwing it up? Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/#findComment-1005629 Share on other sites More sharing options...
ethan6 Posted February 2, 2010 Author Share Posted February 2, 2010 the part that doesn't seem to be working even after i change most vars to $_POST['var'], is the submit button. the button here: <input type="submit" name="submit" value="Submit Comments"></td> doesn't seem to give a value to here: if (isset($_POST['submit'])) { because what's after the isset doesn't get "triggered". But I tested, and $_POST['submit'] does have a value after the form is submitted.. so what's up with the isset? thanks again for the help Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/#findComment-1005636 Share on other sites More sharing options...
wildteen88 Posted February 2, 2010 Share Posted February 2, 2010 Add the following lines at the top of your page. ini_set('display_errors', 1); error_reporting(E_ALL); It should display any errors Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/#findComment-1005637 Share on other sites More sharing options...
ethan6 Posted February 2, 2010 Author Share Posted February 2, 2010 Add the following lines at the top of your page. ini_set('display_errors', 1); error_reporting(E_ALL); It should display any errors I added that to the top and it gave this error: Parse error: syntax error, unexpected T_STRING in /home/itroni5/public_html/contact.php on line 5 .. line 5 is: require_once('inc/mysql.class.php'); which shouldn't be wrong, it's worked fine before. Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/#findComment-1005638 Share on other sites More sharing options...
ethan6 Posted February 2, 2010 Author Share Posted February 2, 2010 Yeah, if I take this top bit off, it seems to work fine. why would that be? <?php // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions require_once('inc/functions.inc.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/#findComment-1005640 Share on other sites More sharing options...
wildteen88 Posted February 2, 2010 Share Posted February 2, 2010 Strange error, I can't see anything wrong with that line. Maybe the error is caused further up. Post lines 1 - 5 here. Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/#findComment-1005643 Share on other sites More sharing options...
ethan6 Posted February 2, 2010 Author Share Posted February 2, 2010 Strange error, I can't see anything wrong with that line. Maybe the error is caused further up. Post lines 1 - 5 here. well it's only when I add that extra "show error" code. And those top lines about includes are what cause the form not to go through.. any ideas why? Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/#findComment-1005645 Share on other sites More sharing options...
wildteen88 Posted February 2, 2010 Share Posted February 2, 2010 Make sure you copied the two lines properly. I know I accidentally added a quote where it shouldn't be but I did update my post. The correct lines are Add the following lines at the top of your page. ini_set('display_errors', 1); error_reporting(E_ALL); It should display any errors Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/#findComment-1005650 Share on other sites More sharing options...
ethan6 Posted February 2, 2010 Author Share Posted February 2, 2010 Make sure you copied the two lines properly. I know I accidentally added a quote where it shouldn't be but I did update my post. The correct lines are Add the following lines at the top of your page. ini_set('display_errors', 1); error_reporting(E_ALL); It should display any errors thanks, got it ..i think i'm going to just take out these lines and it seems to work fine then: // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions require_once('inc/functions.inc.php'); Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/#findComment-1005654 Share on other sites More sharing options...
ethan6 Posted February 2, 2010 Author Share Posted February 2, 2010 ok i just took those top lines out (as well as switched to using $_POST vars) and now i'm good to go. THANKS everybody! Quote Link to comment https://forums.phpfreaks.com/topic/190688-php-form-wont-submit-info/#findComment-1005657 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.