Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Adding reset button to an email form.

Posted on 2005-03-26
14
Medium Priority
?
229 Views
Last Modified: 2006-11-18
Hello,
Could you guys look over my script below and tell me how to add a 'reset' button to the following e-mail form. The Form is in Flash MX.

<?php
$first_name = $_POST['t1'];
$last_name = $_POST['t2'];
$email = $_POST['t3'];
$menu1 = $_POST['t4'];

$message = "First-name: $first_name\n";
$message .= "Last-name: $last_name\n";
$message .= "E-mail: $email\n";
$message .= "Message: $comments\n";

mail ("weikelbob@aol.com",$first_name,$message);
header("Location: http://jibzauctions.com/index.html");
exit;
?>
0
Comment
Question by:weikelbob
  • 9
  • 5
14 Comments
 
LVL 4

Expert Comment

by:sint4x
ID: 13638317
This is the current code to actually email the data, your 1 step a head of yourself. What you need to do is go to the page that sends the user to this one and add the following html by the submit button (preferably): <input name="Reset" type="reset" value="Reset Fields">

That will reset all the fields.

Hope this helps.
0
 
LVL 7

Author Comment

by:weikelbob
ID: 13638322
Working on it...
0
 
LVL 7

Author Comment

by:weikelbob
ID: 13638370
I keep getting an error when I hit 'submit':

Parse error: parse error, unexpected '<' in /home/content/j/b/c/jbcellular1/html/nonf/form.php on line 12

Do you think my server is incompatible with the tag we added? Here's the code with the input tag:


<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$menu1 = $_POST['comments'];

$message = "First-name: $first_name\n";
$message .= "Last-name: $last_name\n";
$message .= "E-mail: $email\n";
$message .= "Message: $comments\n";

<input name="Reset" type="reset" value="Reset Fields">

mail ("weikelbob@aol.com",$first_name,$message);
header("Location: http://jibzauctions.com/nonf/index.html");
exit;
?>
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:sint4x
ID: 13639357
No, this is not the page to edit.

When you are at the form, filling out your email, look at your address bar to see what the name of that file is, then post the code here and I will help you edit it.

P.S. Remove that input line in that script ^^
0
 
LVL 7

Author Comment

by:weikelbob
ID: 13639899
Here's the form.  Let me know if you need more from that file.



<form style="margin:0;color:#438092;margin-left:17px;margin-top:21px" action="form.php" method="post">
                    First Name:<br>
                    <input name="first_name" type="text" id="first_name" style="width:234px;height:19px;font-size:11px;border-color:#C7C7C7;border-style:solid;border-width:1px;background-color:#F3F3F3;margin-top:2px;margin-bottom:6px">
                    <br>
                    Last Name:<br>
                    <input name="last_name" type="text" id="last_name" style="width:234px;height:19px;font-size:11px;border-color:#C7C7C7;border-style:solid;border-width:1px;background-color:#F3F3F3;margin-top:2px;margin-bottom:6px">
                    <br>
                    Email:<br>
                    <input name="email" type="text" id="email" style="width:234px;height:19px;font-size:11px;border-color:#C7C7C7;border-style:solid;border-width:1px;background-color:#F3F3F3;margin-top:2px;margin-bottom:6px">
                    <br>
                    Comments:
                    <textarea name="comments" cols="" rows="" id="comments" style="width:234px;height:155px;font-size:11px;border-color:#C7C7C7;border-style:solid;border-width:1px;background-color:#F3F3F3;margin-top:2px;margin-bottom:6px;overflow:auto"></textarea>
                    <br>
                    <div align="right" style=" padding-right:18px">
                      <input type="image" src="5-but_01.jpg" align="absmiddle" width="90" height="9" border="0">                    
                      <input type="image" onClick="this.Submit()" src="5-but_02.jpg" align="absmiddle" width="90" height="9" border="0">
                     

                              </div>
                </form>
0
 
LVL 4

Expert Comment

by:sint4x
ID: 13639913
<form style="margin:0;color:#438092;margin-left:17px;margin-top:21px" action="form.php" method="post">
                    First Name:<br>
                    <input name="first_name" type="text" id="first_name" style="width:234px;height:19px;font-size:11px;border-color:#C7C7C7;border-style:solid;border-width:1px;background-color:#F3F3F3;margin-top:2px;margin-bottom:6px">
                    <br>
                    Last Name:<br>
                    <input name="last_name" type="text" id="last_name" style="width:234px;height:19px;font-size:11px;border-color:#C7C7C7;border-style:solid;border-width:1px;background-color:#F3F3F3;margin-top:2px;margin-bottom:6px">
                    <br>
                    Email:<br>
                    <input name="email" type="text" id="email" style="width:234px;height:19px;font-size:11px;border-color:#C7C7C7;border-style:solid;border-width:1px;background-color:#F3F3F3;margin-top:2px;margin-bottom:6px">
                    <br>
                    Comments:
                    <textarea name="comments" cols="" rows="" id="comments" style="width:234px;height:155px;font-size:11px;border-color:#C7C7C7;border-style:solid;border-width:1px;background-color:#F3F3F3;margin-top:2px;margin-bottom:6px;overflow:auto"></textarea>
                    <br>
                    <div align="right" style=" padding-right:18px">
                      <input type="image" src="5-but_01.jpg" align="absmiddle" width="90" height="9" border="0">                    
                      <input type="image" onClick="this.Submit()" src="5-but_02.jpg" align="absmiddle" width="90" height="9" border="0">
                      <input name="Reset" type="reset" value="Reset Fields">
                     

                         </div>
                </form>
0
 
LVL 7

Author Comment

by:weikelbob
ID: 13639988
Still does not work. Here's the URL:

http://www.jibzauctions.com/nonf/index-5.html

Bob
0
 
LVL 7

Author Comment

by:weikelbob
ID: 13640127
I was messing with the files a little, i'll stop. Hope I didn't disturb what you were doing.

Bob
0
 
LVL 7

Author Comment

by:weikelbob
ID: 13640425
This is kind of urgent, could someone assist me with this?

Bob
0
 
LVL 4

Accepted Solution

by:
sint4x earned 1500 total points
ID: 13640603
I am afraid it gets a little more complicated when you want to use images to reset the form with, I am going to give you that whole file, as you should use it.

<HTML>
<HEAD>
<TITLE>Contact</TITLE>
<meta http-equiv="Content-Style-Type" content="text/css">
<LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
<style type="text/css">
<!--
.style2 {
      font-size: 11px;
      font-weight: bold;
      font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>

<script  language = "Javascript">
/**
 * DHTML resetting image button forms script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function ResetForm(which) {
    var pass=true
    var first=-1
    if (document.images){
        for (i=0;i<which.length;i++){
            var tempobj=which.elements[i];
            if (tempobj.type=="text"){
                eval(tempobj.value="")

                if (first==-1) {first=i}
            } else if (tempobj.type=="checkbox") {
                eval(tempobj.checked=0)
                if (first==-1) {first=i}
            } else if (tempobj.col!="") {
                eval(tempobj.value="")
                if (first==-1) {first=i}
            }
        }
    }
    return false;
}
</script>

</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 rightmargin="0" bottommargin="0">
<table width="701" height="464" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="240" height="100%" style="padding-top:26px"><TABLE WIDTH=200 BORDER=0 CELLPADDING=0 CELLSPACING=0>
        <TR>
          <TD><a href="index.html"><img src="1-tab_01.jpg" width=96 height=79 alt=""></a></TD>
          <TD><IMG SRC="1-tab_02.jpg" WIDTH=104 HEIGHT=79 ALT=""></TD>
        </TR>
        <TR>
          <TD COLSPAN=2><IMG SRC="1-tab_03.jpg" WIDTH=200 HEIGHT=359 ALT=""></TD>
        </TR>
    </TABLE></td>
    <td width="461" style="padding-bottom:30px "><table width="461" height="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td align="right"><TABLE WIDTH=378 BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
            <TR>
              <TD width="79"><a href="index-1.html"><img src="menu_01.jpg" alt="" width=79 height=26 border="0"></a></TD>
              <TD width="151"><a href="index-2.html"><img src="menu_02.jpg" alt="" width=66 height=26 border="0"></a><a href="index-3.html"><IMG SRC="menu_03.jpg" ALT="" WIDTH=84 HEIGHT=26 border="0"></a></TD>
              <TD width="66"><a href="index-4.html"><IMG SRC="menu_04.jpg" ALT="" WIDTH=62 HEIGHT=26 border="0"></a></TD>
              <TD width="82"><a href="index-5.html"><IMG SRC="menu_05.jpg" ALT="" WIDTH=63 HEIGHT=26 border="0"></a></TD>
            </TR>
          </TABLE></td>
        </tr>
        <tr>
          <td><img src="5-up-1.jpg" width="461" height="23"></td>
        </tr>
        <tr>
          <td height="100%"><table width="461" height="100%" background="images/5-back-1.jpg" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="192" height="100%"><div style=" padding-left:15px;padding-top:18px;padding-right:5px">
                  <p class="style2">JiBz Auctions<br>
                    86 Union ST<br>
                    Peterborough NH 03458<br>
                    Jbcellular@yahoo.com<br>
                    877-382-8941</p>
                </div></td>
                <td width="269"> <form style="margin:0;color:#438092;margin-left:17px;margin-top:21px" action="form.php" method="post">
                    First Name:<br>
                    <input name="first_name" type="text" id="first_name" style="width:234px;height:19px;font-size:11px;border-color:#C7C7C7;border-style:solid;border-width:1px;background-color:#F3F3F3;margin-top:2px;margin-bottom:6px">
                    <br>
                    Last Name:<br>
                    <input name="last_name" type="text" id="last_name" style="width:234px;height:19px;font-size:11px;border-color:#C7C7C7;border-style:solid;border-width:1px;background-color:#F3F3F3;margin-top:2px;margin-bottom:6px">
                    <br>
                    Email:<br>
                    <input name="email" type="text" id="email" style="width:234px;height:19px;font-size:11px;border-color:#C7C7C7;border-style:solid;border-width:1px;background-color:#F3F3F3;margin-top:2px;margin-bottom:6px">
                    <br>
                    Comments:
                    <textarea name="comments" cols="" rows="" id="comments" style="width:234px;height:155px;font-size:11px;border-color:#C7C7C7;border-style:solid;border-width:1px;background-color:#F3F3F3;margin-top:2px;margin-bottom:6px;overflow:auto"></textarea>
                    <br>
                    <div align="right" style=" padding-right:18px">
                      <input type="image" onClick="this.Submit()" src="5-but_02.jpg" align="absmiddle" width="90" height="9" border="0">

                      <input type="image" onClick="ResetForm(this);" name="imgReset" src="5-but_01.jpg" alt="reset" width="62" height="20">

                         </div>
                </form></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td><img src="5-end-1.jpg" width="461" height="23"></td>
        </tr>
    </table></td>
  </tr>
</table>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <th scope="row"><img src="end.jpg" width="750" height="82"></th>
  </tr>
</table>
<p>&nbsp;</p>
</BODY>
</HTML>

Hope that helps!
0
 
LVL 7

Author Comment

by:weikelbob
ID: 13640815
Hi,

Thanks for the script. I cannot get it to work.

The URL to my customer's site is jibzauctions.com/nonf/

Also, here's the form.php that is in the same directory as this script that i named index-5.html.

<?php

$msg = "First Name: " . $_POST['first_name'] . "\n";
$msg = "Last Name: " . $_POST['last_name'] . "\n";
$msg .= "Email: " . $_POST['email'] . "\n";
$msg .= "Comments: " . $_POST['comments'] . "\n";

$recipient = "weikelbob@aol.com";
$subject = "A customer2";

if(mail($recipient, $subject, $msg))
      echo "mail sent !";
else
      echo "Error in sending mail!";

?>


I appreciate the help.
0
 
LVL 4

Expert Comment

by:sint4x
ID: 13641298
What is not working, the reset or the mailer?
0
 
LVL 7

Author Comment

by:weikelbob
ID: 13641322
The reset is not working. Both of the words "submit" and "reset" bring up 'mail sent'
 and they both send me a message ( with the subject being the last name instead of the first name as it should be"

Bob
0
 
LVL 7

Author Comment

by:weikelbob
ID: 13641419
I'm going to switch over to the cgi form mailer way since Godaddy doesn't recognize php very well.

So I'm closing this question.

Bob
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This article discusses four methods for overlaying images in a container on a web page
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

564 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