[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Email Confirmation

Posted on 2014-02-03
5
Medium Priority
?
406 Views
Last Modified: 2014-02-04
I have an email form on an HTML page.  After the email is sent I want the form to disappear and the "Thank You response to appear in it's place on the same page.  How would I do this?

<form action="contactemp.php" method="post">
<table width="601" height="188" style=" border:none;">
<tr>
<td>Please Enter Your Name</td>
<td><input name="cf_name" type="text" size="50"></td>
</tr>
<tr>
<td>Your E-mail Address<br></td>
<td><input name="cf_email" type="text" size="50"></td>
</tr>
<tr>
<td height="86">Send Us A Message</td>
<td><textarea name="cf_message" cols="50" rows="6"></textarea></td>
</tr>
</table>
    
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>

Open in new window


<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];

$mail_to = 'website@mediascrubber.com';
$subject = 'Employment'.$field_name;

$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;

$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

if ($mail_status) { ?>
	<script language="javascript" type="text/javascript">
		alert('Thank you for the message. We will contact you shortly.');
		window.location = 'contact_page.html';
	</script>
<?php
}
else { ?>
	<script language="javascript" type="text/javascript">
		alert('Message failed. Please, send an email to gordon@template-help.com');
		window.location = 'contact_page.html';
	</script>
<?php
}
?>

Open in new window

0
Comment
Question by:DS928
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39831238
This question deeply misunderstands the nature of the PHP mail command and the entire email system.  You might want to contact a professional email service company about this.  Maybe an entity like www.ConstantContact.com could help.  As written you're at the foot of a high and treacherous mountain and you need professional help, quickly, before you're caught in an avalanche!

I don't have enough time left in life to tell you all of the ways that this path can go wrong for you, but I hope you will take my advice and get professional help.  I've spent years wrestling with these issues and I promise you, they are non-value-added and enormously time consuming.
0
 

Author Comment

by:DS928
ID: 39831290
Then how would I just open up a div.  Like a popup?
0
 
LVL 5

Accepted Solution

by:
Martin Tarlink earned 2000 total points
ID: 39831466
In email forms  I usually use switch() function to play with checking email status
You can specify var "check" that will redirect your function depend what status you will have.

switch ('check') {
    case ($_GET['check']=="check");  
    ... checking code here
    break;
    
    case ($_GET['check']=="form");
	emailform();
    break;

    case ($_GET['check']=='success')

    echo "Thank you for sending email";
			 
    break;
}

Open in new window

and the confirmation could be set like this
if ($to!== NULL) {
	mail($to, $sub, $msg, $headers);
		echo nl2br("<h2>Congratulations email was send!!</h2> ");
}

Open in new window

This is a just an idea, it is hart to write whole code because I am not sure what you try to accomplish  eg. my email file is 750 lines long

Regards
Tarlink
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39832055
Then how would I just open up a div.  Like a popup?
Check out the "modal form" in the jQuery UI
https://jqueryui.com/dialog/

But make sure you thoroughly understand Client/Server protocols first!
0
 
LVL 34

Expert Comment

by:Slick812
ID: 39833843
greetings DS928, , You say - " I want the form to disappear and the "Thank You response to appear in it's place on the same page." This is NOT the way a Normal <form> submit works, as the entire page will be refreshed with the new page that the <form> is submitted to in the normal way. . If you want to do page section refresh as "form to disappear" and a "thank You" is shown, , then I would have to use the AJAX javascript browser-server exchange. Unfortunately the Ajax coding is not so easy to understand at first, but it can be something that is very useful for today's user-friendly web sites. I guess you already know that your code example with the javascript output, will not work.
Tell us more about what you need, and there will be more suggestions for you to try.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question