linardzb Posted November 3, 2012 Share Posted November 3, 2012 Hi, my php code seems to be not working, perhaps someone can spot the problem. May thanks. <?php //Make sure that PATH_INFO is set, and not ORIG_PATH_INFO as some hosts seem to use. if (isset ($_SERVER['ORIG_PATH_INFO']) && $_SERVER['ORIG_PATH_INFO'] != $_SERVER['PHP_SELF']) { $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; } if (!empty ($_SERVER['PATH_INFO']) && strrpos ($_SERVER['PHP_SELF'], $_SERVER['PATH_INFO'])) { $_SERVER['PHP_SELF'] = substr ($_SERVER['PHP_SELF'], 0, -(strlen ($_SERVER['PATH_INFO']))); } ?> <?php $error = false; $sent = false; if(isset($_POST['name'])) { if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comments'])) { $error = true; } else { $to = "pamella@origin-designs.co.uk"; $name = trim($_POST['name']); $email = trim($_POST['email']); $comments = trim($_POST['comments']); $subject = "Contact Form"; $messages = "Name: $name \r\n Email: $email \r\n Comments: $comments"; $headers .= 'From: '.$name.' <'.$email.'>' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From:" . $name . "\r\n"; $mailsent = mail($to, $subject, $messages, $headers); if($mailsent) { $sent = true; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/270265-forms/ Share on other sites More sharing options...
codydaig Posted November 4, 2012 Share Posted November 4, 2012 What specifically isn't working? What's the error message? Could you include more details? Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/270265-forms/#findComment-1390045 Share on other sites More sharing options...
linardzb Posted November 4, 2012 Author Share Posted November 4, 2012 Right, there is no error message at all, it is just not running the code properly. It sort of reloads the page and thats it.Thanks Quote Link to comment https://forums.phpfreaks.com/topic/270265-forms/#findComment-1390194 Share on other sites More sharing options...
cyberRobot Posted November 6, 2012 Share Posted November 6, 2012 (edited) Have you tried adding print statements in various spots in the code to see what's getting executed? For example <?php //...snip if(isset($_POST['name'])) { print 'here - name set'; //...snip } ?> You could also try displaying the variables used throughout the code in various spots to make sure they contain what you expect. Edited November 6, 2012 by cyberRobot Quote Link to comment https://forums.phpfreaks.com/topic/270265-forms/#findComment-1390534 Share on other sites More sharing options...
PFMaBiSmAd Posted November 6, 2012 Share Posted November 6, 2012 It's likely that your form isn't submitting the variables that your php code is expecting. What is your form? Quote Link to comment https://forums.phpfreaks.com/topic/270265-forms/#findComment-1390536 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.