Newbie Needs Form Help

Reply

Join Date: Oct 2007
Posts: 5
Reputation: esgdirect is an unknown quantity at this point 
Solved Threads: 0
esgdirect esgdirect is offline Offline
Newbie Poster

Newbie Needs Form Help

 
0
  #1
Oct 26th, 2007
I have a simple Contact form script. I want to change it so it shows the email address of the person sending the form, not mine. I also hope I am pasting this code correctly. Sometimes I get a blank form, but all fields are required. I would like to know who is sending me the form. Also, how can the person sending the form get an email copy of what I receive? In case they entered something wrong? Thanks in advance.

Here is the code:


<?php

// Simple Form Script
// Copyright (C) 2005 Eric Zhang
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// Please send bugs/questions to erkzh@yahoo.com.

//--------------------------Set these paramaters--------------------------


$subject = 'Game Score Report'; // Subject of email sent to you.
$emailadd = 'bpavone@glghl.com'; // Your email address. This is where the form information will be sent.
$url = 'http://www.glghl.com/thank_you.html'; // Where to redirect after form is processed.
$req = '1'; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 45)
{echo "Name of form element $key cannot be longer than 45 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 32
Reputation: StatiX is an unknown quantity at this point 
Solved Threads: 2
StatiX's Avatar
StatiX StatiX is offline Offline
Light Poster

Re: Newbie Needs Form Help

 
0
  #2
Oct 27th, 2007
Just edit the from field to show their email address. You will need to add another form element to your contact form then change the folowing code:

  1. mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
To:
  1. mail($emailadd, $subject, $text, 'From: '.$emailfrom.'');
  2. //set your from address to $emailfrom
  3. //this will get its value from the form

To email both you and the user just add another mail function like:
  1. mail($emailadd, $subject, $text, 'From: '.$emailfrom.''); //email admin
  2. mail($emailfrom, $subject, $text, 'From: '.$emailadd.''); //email user

HTH
StatiX
Always do what you wish you could..
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 5
Reputation: esgdirect is an unknown quantity at this point 
Solved Threads: 0
esgdirect esgdirect is offline Offline
Newbie Poster

Re: Newbie Needs Form Help

 
0
  #3
Oct 28th, 2007
Thanks for your quick reply. I appreciate that. I have attached the html in notepad of the form I use. And I attached a copy of the script with the changes you suggested. When I changed the code the way you told me to, I still receive the form, only there is no email address from the person sending it. It comes from "Unknown Sender" and then the sender of the form does not get an email copy of the form. Thanks in advance. Bill
Attached Files
File Type: txt GLGHL_Representative_Contact_Form[1].txt (13.2 KB, 1 views)
File Type: txt SimpleScript1.txt (1.7 KB, 1 views)
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 32
Reputation: StatiX is an unknown quantity at this point 
Solved Threads: 2
StatiX's Avatar
StatiX StatiX is offline Offline
Light Poster

Re: Newbie Needs Form Help

 
0
  #4
Oct 28th, 2007
From the contact form the user enters a value for their email and is stored in variable $Email. It looks like you just need to use it in your mail function like this:

  1. mail($emailadd, $subject, $text, 'From: '.$Email.''); //email admin
  2. mail($Email, $subject, $text, 'From: '.$emailadd.''); //email user

Note that the variable email is "Email" and not "email". If your server is linux or unix, the capital letter will make a difference.

Let me know how it goes

Regards,
StatiX
Always do what you wish you could..
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 5
Reputation: esgdirect is an unknown quantity at this point 
Solved Threads: 0
esgdirect esgdirect is offline Offline
Newbie Poster

Re: Newbie Needs Form Help

 
0
  #5
Oct 28th, 2007
Still the same. I still get the form but there is is still no return email address and the sender still gets no email.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 5
Reputation: esgdirect is an unknown quantity at this point 
Solved Threads: 0
esgdirect esgdirect is offline Offline
Newbie Poster

Re: Newbie Needs Form Help

 
0
  #6
Oct 29th, 2007
I want to add that the form has a .html extension and is not in the same file as the script. Obviously it is a simple script that was provided with the hosting I have through directadmin. I can change anything that is requested. The website is glghl.com and I have 2 forms on it. http://www.glghl.com/GLGHL_Represent...tact_Form.html and http://www.glghl.com/GLGHL_Game_Score_Form.html

In a nutshell, I want the above attached form to be emailed to me and back to the person who sent it so they can see what they sent me. I also want it to come from their email address, so in case I get a blank form, which has happened 3 times already. I have no idea why. Right now it says I sent the form and if it comes in blank, I have no idea who sent it. I also have all fields required and it can stay that way. The reason I want them to receive an email is because I was told it gets complicated to do code to show them what they entered so they can then send after they check what they filled in.

This is for a hockey league I am running and need help as soon as I can get it. Thanks all in advance.

If someone has a different but simple script, I can change it to let me know.
Last edited by esgdirect; Oct 29th, 2007 at 12:30 am. Reason: Adding a request for a different script.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 32
Reputation: StatiX is an unknown quantity at this point 
Solved Threads: 2
StatiX's Avatar
StatiX StatiX is offline Offline
Light Poster

Re: Newbie Needs Form Help

 
0
  #7
Oct 29th, 2007
Add this code to the bottom of the .php script:
  1.  
  2. echo '<META HTTP-EQUIV=Refresh CONTENT="30; URL='.$url.'">';
  3. echo "<b><br />emailadd var: " .$emailadd;
  4. echo "<br />subject: ".$subject;
  5. echo "<br />text: ".$text;
  6. echo "<br />from: ".$Email;
  7. echo "</b>";
  8.  
  9. ?>


Find out what the vars hold and post them. to see if its not getting set correctly
Always do what you wish you could..
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 5
Reputation: esgdirect is an unknown quantity at this point 
Solved Threads: 0
esgdirect esgdirect is offline Offline
Newbie Poster

Re: Newbie Needs Form Help

 
0
  #8
Oct 29th, 2007
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
echo '<META HTTP-EQUIV=Refresh CONTENT="30; URL='.$url.'">';
echo "<b><br />emailadd var: " .$emailadd;
echo "<br />subject: ".$subject;
echo "<br />text: ".$text;
echo "<br />from: ".$Email;
echo "</b>";


It seemed to change and add the one line. Other than that I have no idea what you are talking about. Thanks again. I am going to look for a book to understand all this. I know html but thats it.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC