 |
|
 |
|
Next: Membership of DB Role when User Gains Access via ..
|
| Author |
Message |
External

Since: Feb 14, 2006 Posts: 2
|
(Msg. 1) Posted: Tue Feb 14, 2006 12:18 am
Post subject: Validating and Passing form data to Thanks Page Archived from groups: alt>php (more info?)
|
|
|
Hi all, SERIOUS newb here just beginning to look into php. I've tried a few
solutions to my issue from snippets I've seen, but so far nothing has
worked.
In an attempt to stop email harvesting and SPAM issues (I get about 2,400
every 24 hours), I'm making my contact forms use the php form handler from
Sitewizard. The email from the form sends OK, and my Thanks page loads, but
I'd like to carry the value the user entered for their email into the Thanks
page. Previously I used a FrontPage component to show it, but putting this:
<?
print "Email you entered is $_POST['email']\n";
?>
just leaves that part of the page blank. I tried using a php extension on
the page instead of htm, but that didn't help. PHP does work on the Windows
2003 server.
The Sitewizard form has the following:
<form action="feedback.php" method="post">
<table border="0" cellpadding="8" cellspacing="8" summary="feedback form">
<tr><td>Name:</td><td><input type="text" name="name" size="25" /></td></tr>
<tr><td>Email address:</td><td><input type="text" name="email" size="25"
/></td></tr>
<tr>
<td colspan="2">
Comments<br />
<textarea rows="15" cols="45" name="comments">
</textarea>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Send Feedback" /><br />
</td>
</tr>
</table>
</form>
The Sitewizard formhandler (feedback.php) has the following (with the actual
working entries replaced w/ generic labels):
<?
$mailto = 'MyEmailAddress';
$subject = "Email Subject Line" ;
$formurl = "URL_of_form.htm" ;
$errorurl = "URL_of_Error_page.htm" ;
$thankyouurl = "URL_of_ThanksPage.htm" ;
ini_set ("SMTP", "mymailserver");
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}
$name = strtok( $name, "\r\n" );
$email = strtok( $email, "\r\n" );
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}
$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;
mail($mailto, $subject, $messageproper, "From: \"$name\"
<$email>\r\nReply-To: \"$name\" <$email>\r\nX-Mailer: chfeedback.php
2.04" );
header( "Location: $thankyouurl" );
exit ;
?>
On the Thanks page, I tried putting:
<?
print "You entered email as $_POST ['email']\n" ;
?>
and several other variations, excluding the apostrophes, then the brackets,
several different combinations, etc.; you know, the usual attempts to see if
the problem was my syntax.
Can anyone tell me how this can be done?
If you have the time, I'd also like to know if there's a way with php to
validate that the email field was filled in (currently use FrontPage's
validation rule that just pops up a "no email address" error when user
attempts to click Send button).
If this belongs in a different group, please lead me in the right direction.
Thanks for reading, and for any help. I hope I don't wear out my welcome
while I start learning php. >> Stay informed about: Validating and Passing form data to Thanks Page |
|
| Back to top |
|
 |  |
External

Since: Feb 13, 2006 Posts: 1
|
(Msg. 2) Posted: Tue Feb 14, 2006 12:18 am
Post subject: Re: Validating and Passing form data to Thanks Page [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
I'm also a supreme newb so beware.
print "You entered email as $_POST ['email']\n" ; doesn't work because
you POSTed to "feedback.php" not to your thanks page. My newbie fix
would be to modify the last few lines of feedback.php like this:
----------SNIPPET-------------
$email = rawurlencode($email);
header( "Location: $thankyouurl?email=$email" );
exit ;
----------END SNIPPET-------------
Then modify your thanks page like this:
<?
$email = rawurldecode($_GET['email']);
print "You entered email as $email\n";
?>
Second question:
It looks like feedback.php already verifies that the user entered
something (not necessarily an email address) in the email field.
----------SNIPPET-------------
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
----------END SNIPPET-------------
Again, I'm a newb so use at your own risk. >> Stay informed about: Validating and Passing form data to Thanks Page |
|
| Back to top |
|
 |  |
External

Since: Jan 23, 2006 Posts: 3
|
(Msg. 3) Posted: Tue Feb 14, 2006 6:55 am
Post subject: Re: Validating and Passing form data to Thanks Page [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On 2006-02-14, Newbie Supreme wrote:
> Hi all, SERIOUS newb here just beginning to look into php. I've tried a few
> solutions to my issue from snippets I've seen, but so far nothing has
> worked.
>
> In an attempt to stop email harvesting and SPAM issues (I get about 2,400
> every 24 hours), I'm making my contact forms use the php form handler from
> Sitewizard. The email from the form sends OK, and my Thanks page loads, but
> I'd like to carry the value the user entered for their email into the Thanks
> page. Previously I used a FrontPage component to show it, but putting this:
>
><?
> print "Email you entered is $_POST['email']\n";
> ?>
> just leaves that part of the page blank. I tried using a php extension on
> the page instead of htm, but that didn't help. PHP does work on the Windows
> 2003 server.
what do you see when you view the page source in your browser?
I'm guessing here, but you could try changing <? to <?php
it's a configuration thing...
also
$_POST['email']
when _inside_ quotes should be
$_POST[email]
Bye.
Jasen >> Stay informed about: Validating and Passing form data to Thanks Page |
|
| Back to top |
|
 |  |
External

Since: Feb 14, 2006 Posts: 2
|
(Msg. 4) Posted: Tue Feb 14, 2006 12:54 pm
Post subject: Re: Validating and Passing form data to Thanks Page [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
mismacku, you were dead on, it works great making the changes you suggested.
Newb my butt:>).
Thanks very much for the help.
"mismacku" wrote in message
> I'm also a supreme newb so beware.
>
> print "You entered email as $_POST ['email']\n" ; doesn't work because
> you POSTed to "feedback.php" not to your thanks page. My newbie fix
> would be to modify the last few lines of feedback.php like this:
>
> ----------SNIPPET-------------
> $email = rawurlencode($email);
> header( "Location: $thankyouurl?email=$email" );
> exit ;
> ----------END SNIPPET-------------
>
> Then modify your thanks page like this:
> <?
> $email = rawurldecode($_GET['email']);
> print "You entered email as $email\n";
> ?>
>
> Second question:
> It looks like feedback.php already verifies that the user entered
> something (not necessarily an email address) in the email field.
>
> ----------SNIPPET-------------
> if (!isset($_POST['email'])) {
> header( "Location: $formurl" );
> exit ;
> ----------END SNIPPET-------------
>
> Again, I'm a newb so use at your own risk.
> >> Stay informed about: Validating and Passing form data to Thanks Page |
|
| Back to top |
|
 |  |
| Related Topics: | passing array to top page in frameset not working? - Hello, The following <frame src="topbar-frameset.php?newVar=<?php echo $groups; ?>"> passes the value of the variable $groups from a php file to the top page in a frameset but how do I change it if $groups is an array? Cheers, ...
Help with two page form - Hello All, I am in need of some help. I have an order form for a website I am working on and it consists of two pages. The first page gathers most of the information for the order and inserts that into a database table, which works fine. The user the...
POST form to dynamic page name - I've got a simple form with an HTML OPTION block. I'd like to POST the form to a page whose name is based on the OPTION they select. So for example say the user selected this option, I'd like to POST the form to a page named "memory.php". ech...
Passing data between class instances - Usinge PHP 4.1.2 I have a contoller script that builds page objects based on their properties stored in the db. for example: I have a useradmin object to allow users to modify user records in the db. I have two instances of the object being put into....
Options for Validating a Date Value? - Surprisingly (at least to me), there doesn't seem to be a built-in function to validate a date value (like, say, is_date()). Given that, is there a best practice for determining whether a value is a valid date/time? The values I need to test will likel... |
|
You can post new topics in this forum You can 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
|
|
|
|
 |
|
|