0

First of all, please check out my other post. http://www.daniweb.com/forums/post1318472.html#post1318472

Ok, hello everybody! I have a question that should be pretty simple.
I have a php page that will send an email. I got that all working fine.

<?php
 $to = "reciever@example.com";
 $subject = "Test Subject";
 $body = "Test Body";
 $headers = "From: sender@example.com\r\n" .
     "X-Mailer: php";
 if (mail($to, $subject, $body, $headers)) {
   echo("<p>Message sent!</p>");
  } else {
   echo("<p>Message delivery failed...</p>");
  }
 ?>

But what I need to do is make it so when you click that button, it will send the email, and not send it before clicking it. Optionaly, but it isn't necessary would be to change the button's name once it sends it from "send email" to "didn't receive it yet? send it again". Thank you! I would really love some help!
Thanks in advance!
-Keavon

2
Contributors
12
Replies
27
Views
7 Years
Discussion Span
Last Post by keavon
Featured Replies
  • 1

    [CODE] <?php if( isset($_POST['Submitter']) && !empty($_POST['Submitter']) ) { $to = "reciever@example.com"; $subject = "Test Subject"; $body = "Test Body"; $headers = "From: sender@example.com\r\n" . "X-Mailer: php"; if (mail($to, $subject, $body, $headers)) { echo("<p>Message sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } exit(); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 … Read More

  • 1

    Then just get rid of the [icode]<html>...</html>[/icode]. On the page you are submitting FROM you need your submit button to have [icode]name="Submitter"[/icode] for the php code above to work. Read More

  • 1

    When I go to the link you posted and then look at the browser's source code I am seeing: [CODE=html] <form action="verify.php"...> ... <form action="javascript:alert('enable');"> <input type="submit" id="Submitter" value="Continue to next step" disabled="disabled" /> </form> ... </form> [/CODE] That is NOT valid html and some browsers "choke" on it. You … Read More

1
<?php
if( isset($_POST['Submitter']) && !empty($_POST['Submitter']) )
{
 $to = "reciever@example.com";
 $subject = "Test Subject";
 $body = "Test Body";
 $headers = "From: sender@example.com\r\n" .
     "X-Mailer: php";
 if (mail($to, $subject, $body, $headers)) {
   echo("<p>Message sent!</p>");
  } else {
   echo("<p>Message delivery failed...</p>");
  }
  exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>
<body>
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<input type="checkbox" name="agree" value="yes" onclick="Submitter.disabled = !this.checked" />Do you Agree?
<input type="submit" name="Submitter" id="Submitter" value="Submit" disabled="disabled"/>
</form></body>
</html>
Votes + Comments
It was very fast and worked pretty well. He helped me later on in an other post too.
0

Err... Thanks for the post, but the code in the body tags was for my other question, graying out the submit button. Would you please fix that? Thanks, in the mean time, i'll toy around and see if I can get it working.
Thanks!

Edited by keavon: n/a

1

Then just get rid of the <html>...</html> . On the page you are submitting FROM you need your submit button to have name="Submitter" for the php code above to work.

0

That didn't work if I understand you right
try going to [url]http://www.projectflyffinnovation.com/php/index.php[/url]
just fill out something random like 123-456-7890 (it doesn't work yet), then push agree (thanks for helping me with that part, it works great!) and submit. You will see what happens. Here is the current page's source:

<?php
if( isset($_POST['Submitter']) && !empty($_POST['Submitter']) )
{
 $to = "example@example.com";
 $subject = "Test Subject";
 $body = "Test Body";
 $headers = "From: example@example.com\r\n" .
     "X-Mailer: php";
 if (mail($to, $subject, $body, $headers)) {
   echo("<p>Message sent!</p>");
  } else {
   echo("<p>Message delivery failed...</p>");
  }
  exit();
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Verify SMS reminder sign-up</title>
<link rel="Shortcut Icon" href="/favicon.ico">

</head>
<body>
<font face="Arial, Helvetica, sans-serif">
Step 5.<br />
Make sure the info you entered is correct. If it's fine, skip this step.<br />If it's wrong, click the button to correct it.

  <?php

// use it
echo "You entered:<br /><i>Cell phone carrier:</i><b> $carrier</b><br /><i>Cell phone number:</i><b> $number1-$number2-$number3</b>";

  ?>


<form><input type="button" value="Woops, let me fix a mistake" onClick="history.go(-1);return true;"></form>
<br />
Step 6.<br />
To make sure that the number you entered is actually yours, we will send a text message to "your" phone.<br />
In the message you will find a 3 didget code. Enter that in the text box that asks for it. You may now click<br />
the button below to send the pin to your phone. If you do not recieve the pin within 5 minutes, click it again.<br />


<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<input type="submit" name="Submitter" id="Submitter" value="Send the code to my phone" />
</form>


</font>

</body>
</html>

I want to make that "send the code to my phone" button (which all I want to do is send an email) send the email. You can also see the glitched up stuff at the top
xD
Thanks! I hope this clears it up for you and me.

Edited by pritaeas: Removed email address.

0

Hugh, what the heck? now it's working! That's really wield. It didn't work last time I tried and I didn't update it since!

1

When I go to the link you posted and then look at the browser's source code I am seeing:

<form action="verify.php"...>
   ...
  <form action="javascript:alert('enable');"> 
  <input type="submit" id="Submitter" value="Continue to next step" disabled="disabled" /> 
  </form> 
...
</form>

That is NOT valid html and some browsers "choke" on it. You are NOT allowed to nest form tags:

WRONG:

<form>
  <form>...</form>
</form>

CORRECT:

<form>...</form>
<form>...</form>

So on your code get rid of the inner <form> and leave only the submit button <input type="submit" id="Submitter" value="Continue to next step" disabled="disabled" />

0

Thanks for the tip, I just fixed it, but we are really on a different page (literally!). This whole topic should be about the page /verify.php, not /index.php
I'm still glad you pointed that out tho!
I'm going to mark this one as solved, and explain how to do it in case people Googleing it want to know how I did it.
I would really appreciate some help on some other but I'm getting on the verify page.
Thanks!

0

Ok, people who would like to know how I did it, here you go:

<?php
if( isset($_POST['Submitter']) && !empty($_POST['Submitter']) )
{
 $to = "reciever@example.com";
 $subject = "Test Subject";
 $body = "Test Body";
 $headers = "From: sender@example.com\r\n" .
     "X-Mailer: php";
 if (mail($to, $subject, $body, $headers)) {
   echo("<p>Message sent!</p>");
  } else {
   echo("<p>Message delivery failed...</p>");
  }
  exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Page Title Here</title>
</head>
<body>
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<input type="submit" name="Submitter" id="Submitter" value="Button Name here" />
</form>
</body>
</html>
0

It is, but I removed one line that wasn't part of it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.