Akku Posted December 13, 2017 Share Posted December 13, 2017 Hi there, Is there any mistake in the following code? <?php if(isset($_POST['submit'])) { $fname=$_POST['fname']; $lname=$_POST['lname']; $email=$_POST['email']; $phone=$_POST['phone']; $cname=$_POST['cname']; $reason=$_POST['reason']; $web=$_POST['web']; $smart=$_POST['smart']; $im=$_POST['im']; $cd=$_POST['cd']; $ms=$_POST['ms']; $con='Firstname:'.$fname."<br>Lastname:".$lname."<br>Email:".$email."<br>Phone:".$phone."<br>Company:".$cname."<br>Reason:".$reason."<br>".$web."<br>".$smart."<br>".$im."<br>".$cd."<br>".$ms; $to="aaa@bbb.com"; $sub="invoice"; mail($to,$sub,$con); if( mail($to,$sub,$con)) { echo "<script type='text/javascript'>alert('submitted successfully!')</script>"; } } ?> Link to comment Share on other sites More sharing options...
Ingolme Posted December 13, 2017 Share Posted December 13, 2017 The only problem I see is that you're sending the mail twice. What happens when you run the code? Link to comment Share on other sites More sharing options...
Akku Posted December 14, 2017 Author Share Posted December 14, 2017 i didn't receive the mail, is there any problem with the string concatenation or do i have to include any new line properties(if so, i don't know how)? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 14, 2017 Share Posted December 14, 2017 Do you see the alert message? You should add an else to that if statement to print something if sending the mail fails so you always get output from the code. Link to comment Share on other sites More sharing options...
dsonesuk Posted December 15, 2017 Share Posted December 15, 2017 As it is now, it should work, I presume you have local or hosting server with email functionality included? Link to comment Share on other sites More sharing options...
dsonesuk Posted December 15, 2017 Share Posted December 15, 2017 testing script $_POST['submit'] = "yes"; if (isset($_POST['submit'])) { $fname = $_POST['fname'] = "fred"; $lname = $_POST['lname'] = "flintstone"; $email = $_POST['email'] = "this@mail.com"; $phone = $_POST['phone'] = "0123456789"; $cname = $_POST['cname'] = "what"; $reason = $_POST['reason'] = "because i said so"; $web = $_POST['web'] = "spiders"; $smart = $_POST['smart'] = "very"; $im = $_POST['im'] = "md"; $cd = $_POST['cd'] = "cd"; $ms = $_POST['ms'] = "ms"; var_dump($_POST); $con = 'Firstname:' . $fname . "\nLastname:" . $lname . "\nEmail:" . $email . "\nPhone:" . $phone . "\nCompany:" . $cname . "\nReason:" . $reason . "\n" . $web . "\n" . $smart . "\n" . $im . "\n" . $cd . "\n" . $ms; $to = "aaa@bbb.com"; $sub = "invoice"; if (mail($to, $sub, $con)) { echo "<script type='text/javascript'>alert('submitted successfully!')</script>"; } else { echo "ERROR, ERROR Doctor Smith ERROR"; } } if it works, then you need to make sure the $_POST array values and required 'submit value is getting to this script. the var_dump($_POST); will show what is sent. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now