 | Thank you message |  |
|
john barrett
| Joined: 04 Nov 2005 |
| Posts: 41 |
| Location: Hawaii |
|
 |
Posted: Sat Jun 17, 2006 7:51 am |
|
 |
 |
 |
 |
Hi All,
Thanks for all your help, but I have one more, final question--Please Help--
How to I display a varibale that was inputed in the form? That is;
name: John (this was entered in the form)
<?php
$your_email = "myemail@email.com";
// This is what is displayed in the email subject line
// Change it if you want
$subject = "Announcements and Events";
// This is displayed if all the fields are not filled in
$empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>";
// This is displayed when the email has been sent
$thankyou_message = "
Thank you for contacting <span class=SpellE>Nutrition<em><sup>ATC</sup></em></span> with your event. <br>
Your event has been recieved, and it will be posted to the web site soon.<br>
If we have any questions, we will contact you shortly.</p>
<b>Your information was submitted as follows</b>: <br>
Name: $name<br>
E-mail Address: $email <br>
Date(s): $date <br>
Title of Event:$title<br>
Location: $location<br>
Additional Inforamtion:$question <br>";
$name = stripslashes($_POST['user_name']);
$email = stripslashes($_POST['user_email']);
$date = stripslashes($_POST['date']);
$date="Date:"." ".$date."\n";
$title = stripslashes($_POST['title']);
$title ="Title:"." ".$title."\n";
$location = stripslashes($_POST['location']);
$location ="Location:"." ".$location."\n";
$question = stripslashes($_POST['question']);
$question="Additional Information:"." ".$question."\n";
$total_message = "Name:"." ".$name."\n"."E-Mail from:"." ".$email."\n".$date.$title.$location.$question;
if (!isset($_POST['user_name'])) {
?>
|
I thought that if I included the variable ($user_name), I also tried echo, but neither worked.
Any help would be great
Thank you very much,
John
|
|
|
 |
 | |  |
|
dbodner
| Joined: 21 Dec 2005 |
| Posts: 112 |
| Location: Philadelphia, Pa |
|
 |
Posted: Sat Jun 17, 2006 1:36 pm |
|
 |
 |
 |
 |
You should be able to just do:
| echo "Name: $user_name <Br>"; |
Make sure the variable is inside the quotes.
|
|
|
|
john barrett
| Joined: 04 Nov 2005 |
| Posts: 41 |
| Location: Hawaii |
|
 |
Posted: Sat Jun 17, 2006 1:47 pm |
|
 |
 |
 |
 |
Hi dbodner,
Thanks for your reply, but I get a parse error with that.
| Parse error: parse error in /vservers/johnbarr/htdocs/NutritionATC/add_event.php on line 69 |
Tried with echo with-out echo, many different ways
I have been trying to figure this out all night, I feel really stuck
Thanks so much for your help
|
|
|
|
pmeserve
HostMySite Tech
|
 |
Posted: Sat Jun 17, 2006 2:25 pm |
|
 |
 |
 |
 |
John,
It would probably help if we could look at a full copy of your script. Could you post the PHP script in here:
http://pastebin.com/
and send us the link to it? Thanks
|
|
|
|
john barrett
| Joined: 04 Nov 2005 |
| Posts: 41 |
| Location: Hawaii |
|
 |
Posted: Sun Jun 18, 2006 3:34 am |
|
 |
 |
 |
 |
Hi pmeserve,
Thanks so much for your help, I really apreiate it very much
I posted the script on the site you gave, that is cool!
I also have the script here:
http://67.59.131.1/script.txt
Hopefully, you can help me with this.
Basically what I am trying to do is when the user fills the form, is to give a message about that.
Example:
your entered:user_name=John
or something like that
Thanks so much,
|
|
|
 |
 | |  |
|
dbodner
| Joined: 21 Dec 2005 |
| Posts: 112 |
| Location: Philadelphia, Pa |
|
 |
Posted: Sun Jun 18, 2006 5:35 am |
|
 |
 |
 |
 |
$thankyou_message = " Thank you for contacting <span class=SpellE>Nutrition<em><sup>ATC</sup></em></span> with your event. <br>
Your event has been recieved, and it will be posted to the web site soon.<br>
If we have any questions, we will contact you shortly.</p>
<b>Your information was submitted as follows</b>: <br>
echo "Name: $name <Br>";
echo "E-mail Address: $email <br>";
echo "Date(s): $date <br>";
echo "Title of Event:$title<br> ";
echo "Location: $location<br>";
echo "Additional Inforamtion:$question <br>"; |
The thank you message is never ended with a closing ". So the echo (a new PHP call) will give you a parse error, as the assignment of $thankyou_message was never finished. Try changing it to:
$thankyou_message = " Thank you for contacting <span class=SpellE>Nutrition<em><sup>ATC</sup></em></span> with your event. <br>
Your event has been recieved, and it will be posted to the web site soon.<br>
If we have any questions, we will contact you shortly.</p>
<b>Your information was submitted as follows</b>: <br>";
echo "Name: $name <Br>";
echo "E-mail Address: $email <br>";
echo "Date(s): $date <br>";
echo "Title of Event:$title<br> ";
echo "Location: $location<br>";
echo "Additional Inforamtion:$question <br>"; |
Also, i before e, except after c
| Your event has been recieved |
|
|
|
 |
 | |  |
|
john barrett
| Joined: 04 Nov 2005 |
| Posts: 41 |
| Location: Hawaii |
|
 |
Posted: Sun Jun 18, 2006 6:11 am |
|
 |
 |
 |
 |
Hi dbodner,
Thanks so much for your help, that did not do the trick
When I used the echo, like in your code, it always displayed what was echoed, but not just after when the form was filled out. That is, I just want to display the name=whatever after the form was filled out. therefore I changed the echo code to this:
$thankyou_message = "
Thank you for contacting <span class=SpellE>Nutrition<em><sup>ATC</sup></em></span> with your event. <br>
Your event has been recieved, and it will be posted to the web site soon.<br>
If we have any questions, we will contact you shortly.</p>
<b>Your information was submitted as follows</b>: <br>
Name: $name <br>
E-mail Address: $email <br>
Date(s): $date <br>
Title of Event:$title<br>
Location: $location<br>
Additional Inforamtion:$question <br>";
|
this made it so it only displayed after the form was filled out, but did not pass the variables
Thanks again for your help,
John
|
|
|
 |
 | |  |
|
pmeserve
HostMySite Tech
|
 |
Posted: Sun Jun 18, 2006 4:40 pm |
|
 |
 |
 |
 |
John, is that code above the lines like:
$name = stripslashes($_POST['user_name']);
?
If so that will cause issues. One thing I always do when writing a new PHP script is add these lines to the very top:
error_reporting(E_ALL);
ini_set("display_errors", "On");
|
You'll want to comment them out once the script is done, but while you're writing code it will make it much easier to see errors and warnings, for example if you try to output an unset variable(which I suspect it what's happening). It's often a lot easier than trying to track down problems based on warning messages than based on the actual behavior of the problem
|
|
|
 |
 | |  |
|
john barrett
| Joined: 04 Nov 2005 |
| Posts: 41 |
| Location: Hawaii |
|
 |
Posted: Mon Jun 19, 2006 11:23 am |
|
 |
 |
 |
 |
Hi pmeserve,
Thanks for your help. I used your code, and I see that I get this error:
Notice: Undefined index: user_name in /vservers/johnbarr/htdocs/NutritionATC/add_event.php on line 68
Notice: Undefined index: user_email in /vservers/johnbarr/htdocs/NutritionATC/add_event.php on line 69
Notice: Undefined index: date in /vservers/johnbarr/htdocs/NutritionATC/add_event.php on line 71
Notice: Undefined index: title in /vservers/johnbarr/htdocs/NutritionATC/add_event.php on line 74
Notice: Undefined index: location in /vservers/johnbarr/htdocs/NutritionATC/add_event.php on line 77
Notice: Undefined index: question in /vservers/johnbarr/htdocs/NutritionATC/add_event.php on line 81
Notice: Undefined variable: user_name in /vservers/johnbarr/htdocs/NutritionATC/add_event.php on line 88
|
I don't understand while it says that the variables are undenified. As when I use the form, it sends the data to the e-mail, but I can't display it on the page. Oh no, I am so lost on this 
|
|
|
 |
 | |  |
|
dbodner
| Joined: 21 Dec 2005 |
| Posts: 112 |
| Location: Philadelphia, Pa |
|
 |
Posted: Mon Jun 19, 2006 12:21 pm |
|
 |
 |
 |
 |
Can you re-post the updated code?
|
|
|
 |
 | |  |
|
john barrett
| Joined: 04 Nov 2005 |
| Posts: 41 |
| Location: Hawaii |
|
 |
Posted: Tue Jun 20, 2006 1:18 am |
|
 |
 |
 |
 |
Hi dbodner,
Thanks for your help, I have been looking at this for 2 hours
I am going to buy a book on php.
Thanks for all your help,
here is the code,
Thanks,
John
<?php
error_reporting(E_ALL);
ini_set("display_errors", "On");
/**
* Change the email address to your own.
*
* $empty_fields_message and $thankyou_message can be changed
* if you wish.
*/
// Change to your own email address
$your_email = "johnbarr@hawaii.edu";
// This is what is displayed in the email subject line
// Change it if you want
$subject = "Announcements and Events";
// This is displayed if all the fields are not filled in
$empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>";
// This is displayed when the email has been sent
$thankyou_message = " Thank you <br>
<b>Your information was submitted as follows</b>: <br>
Name: $name <br>
E-mail Address: $email <br>
Date(s): $date <br>
Title of Event:$title<br>
Location: $location<br>
Additional Inforamtion:$question <br>";
// You do not need to edit below this line
$name = stripslashes($_POST['name']);
$email = stripslashes($_POST['email']);
$date = stripslashes($_POST['date']);
$date="Date:"." ".$date."\n";
$title = stripslashes($_POST['title']);
$title ="Title:"." ".$title."\n";
$location = stripslashes($_POST['location']);
$location ="Location:"." ".$location."\n";
$question = stripslashes($_POST['question']);
$question="Additional Information:"." ".$question."\n";
$total_message = "Name:"." ".$name."\n"."E-Mail from:"." ".$email."\n".$date.$title.$location.$question;
if (!isset($_POST['name'])) {
?>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<table border="0">
<tr>
<td width="71"> Name: </td>
<td width="450">
<input name="name" type="text" id="name" size="55"></td>
</tr>
<tr>
<td> Email: </td>
<td>
<input name="email" type="text" id="email" size="55"></td>
</tr>
<tr>
<td> Date(s):</td>
<td>
<input name="date" type="text" id="date" size="55"></td>
</tr>
<tr>
<td>Title of Event:</td>
<td>
<input name="title" type="text" id="title" size="55"></td>
</tr>
<tr>
<td height="31">Location:</td>
<td>
<input name="location" type="text" id="location" size="55"></td>
</tr>
</tr>
<tr>
<td>Additional Information:</span><br></td>
<td ><textarea name="question" cols="55" rows="7" wrap="virtual"></textarea>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td height="40"><input name="Submit" type="submit" value="Sumbit">
<input name="Reset" type="reset" value="Clear"></td>
</tr>
</table>
</form>
<?php
}
elseif (empty($name) || empty($email)) {
echo $empty_fields_message;
}
else {
// Stop the form being used from an external URL
// Get the referring URL
$referer = $_SERVER['HTTP_REFERER'];
// Get the URL of this page
$this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
// If the referring URL and the URL of this page don't match then
// display a message and don't send the email.
if ($referer != $this_url) {
echo "You do not have permission to use this script from another URL.";
exit;
}
// The URLs matched so send the email
mail($your_email, $subject, $total_message, "From: $name <$email>");
// Display the thankyou message
echo $thankyou_message;
}
?>
|
|
|
|
 |
 | |  |
|
pmeserve
HostMySite Tech
|
 |
Posted: Fri Jun 23, 2006 3:00 pm |
|
 |
 |
 |
 |
John,
I rearranged the code a bit and I believe it now works as expected. Try this:
<?php
error_reporting(E_ALL);
ini_set("display_errors", "On");
/**
* Change the email address to your own.
*
* $empty_fields_message and $thankyou_message can be changed
* if you wish.
*/
// Change to your own email address
$your_email = "johnbarr@hawaii.edu";
// This is what is displayed in the email subject line
// Change it if you want
$subject = "Announcements and Events";
// This is displayed if all the fields are not filled in
$empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>";
// You do not need to edit below this line
if (!isset($_POST['name'])) {
?>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<table border="0">
<tr>
<td width="71"> Name: </td>
<td width="450">
<input name="name" type="text" id="name" size="55"></td>
</tr>
<tr>
<td> Email: </td>
<td>
<input name="email" type="text" id="email" size="55"></td>
</tr>
<tr>
<td> Date(s):</td>
<td>
<input name="date" type="text" id="date" size="55"></td>
</tr>
<tr>
<td>Title of Event:</td>
<td>
<input name="title" type="text" id="title" size="55"></td>
</tr>
<tr>
<td height="31">Location:</td>
<td>
<input name="location" type="text" id="location" size="55"></td>
</tr>
</tr>
<tr>
<td>Additional Information:</span><br></td>
<td ><textarea name="question" cols="55" rows="7" wrap="virtual"></textarea>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td height="40"><input name="Submit" type="submit" value="Sumbit">
<input name="Reset" type="reset" value="Clear"></td>
</tr>
</table>
</form>
<?php
}
elseif (empty($_POST['name']) || empty($_POST['email'])) {
echo $empty_fields_message;
}
else {
$name = stripslashes($_POST['name']);
$email = stripslashes($_POST['email']);
$date = stripslashes($_POST['date']);
$date="Date:"." ".$date."\n";
$title = stripslashes($_POST['title']);
$title ="Title:"." ".$title."\n";
$location = stripslashes($_POST['location']);
$location ="Location:"." ".$location."\n";
$question = stripslashes($_POST['question']);
$question="Additional Information:"." ".$question."\n";
$total_message = "Name:"." ".$name."\n"."E-Mail from:"." ".$email."\n".$date.$title.$location.$question;
// This is displayed when the email has been sent
$thankyou_message = " Thank you <br>
<b>Your information was submitted as follows</b>: <br>
Name: $name <br>
E-mail Address: $email <br>
Date(s): $date <br>
Title of Event:$title<br>
Location: $location<br>
Additional Inforamtion:$question <br>";
// Stop the form being used from an external URL
// Get the referring URL
$referer = $_SERVER['HTTP_REFERER'];
// Get the URL of this page
$this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
// If the referring URL and the URL of this page don't match then
// display a message and don't send the email.
if ($referer != $this_url) {
echo "You do not have permission to use this script from another URL.";
exit;
}
// The URLs matched so send the email
mail($your_email, $subject, $total_message, "From: $name <$email>");
// Display the thankyou message
echo $thankyou_message;
}
?> |
|
|
|
 |
 | |  |
|
john barrett
| Joined: 04 Nov 2005 |
| Posts: 41 |
| Location: Hawaii |
|
 |
Posted: Sat Jun 24, 2006 1:35 pm |
|
 |
 |
 |
 |
Hi pmeserve,
thank you so very much
I can't tell you how much it means to me that you took the time to figure out how to make this problem work.
The code you wrote works like a dream, thanks so much.
Please let me know if there is anything I can ever do for you, thanks for all your help
You can see the test page at:
http://67.59.131.1/NutritionATC/add_event.php
Thank you so much!
John
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT
Page 2 of 2
|
|
|
|
|