Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP Form Please Help!
Old 09-24-2008, 11:22 PM PHP Form Please Help!
VMC
Junior Talker

Posts: 3
Name: Victoria Colotta
Location: New Jersey
Trades: 0
I have created a form that directs to a thanks.php. Now all of a sudden it isn't working and I think that it could be because the hosting is now PHP 5 x.

Below is the code that I have and the errors that I am getting. Can some please help.

<script language="php">
$email = $HTTP_POST_VARS[email];
$mailto = "email@email.com";
$mailsubj = "Form Name";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }
</script>


Errors:

Warning: reset() [function.reset]: Passed variable is not an array or object in

Warning: Variable passed to each() is not an array or object in /
VMC is offline
Reply With Quote
View Public Profile Visit VMC's homepage!
 
 
Register now for full access!
Old 09-25-2008, 01:40 AM Re: PHP Form Please Help!
dWhite
Guest

Posts: n/a
Trades:
I don't think the PHP parser can parse that code, since the PHP code inside the opener/closer tags is wrong.

<?php
?>

Is supposed to be the opener and closer tags for PHP to be parsed.
Reply With Quote
 
Old 09-25-2008, 01:43 AM Re: PHP Form Please Help!
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Your problem is with the use of $HTTP_POST_VARS - deprecated as of php5. Use the $_POST array instead.

PHP Code:
<?php 
$email 
$_POST['email'];
$mailto "email@email.com";
$mailsubj "Form Name";
$mailhead "From: $email\n";
reset ($_POST); // is this really necessary?
$mailbody "Values submitted from web site form:\n";
foreach (
$_POST as $key=>$val) { $mailbody .= "$key : $val\n"; }
if (!
eregi("\n",$_POST['email'])) { mail($mailto$mailsubj$mailbody$mailhead); }
?>
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 09-25-2008, 09:05 AM Re: PHP Form Please Help!
VMC
Junior Talker

Posts: 3
Name: Victoria Colotta
Location: New Jersey
Trades: 0
Thank you. This worked perfectly.
VMC is offline
Reply With Quote
View Public Profile Visit VMC's homepage!
 
Reply     « Reply to PHP Form Please Help!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13728 seconds with 12 queries