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
Contact Form Help (Convert $_POST to $_GET?)
Old 08-09-2008, 11:21 PM Contact Form Help (Convert $_POST to $_GET?)
Junior Talker

Posts: 1
Trades: 0
Hi... I'm new to this...

I need to get a form based on $_POST TO $_GET... I get a 405 error with $_POST and with $_GET nothing happens..

The code is

contact.html

<form action="script.php" method="get">
<table width="901" align=center bordercolor="#FFFFFF" bgcolor=#FFFFFF>
<tr>
<td colspan=2><div align="center" class="style31 style18">
<p class="style19">Contact Form</p>
<p>&nbsp;</p>
</div></td>
</tr>
<tr>
<td><span class="style16"><font color=red>*</font> Person:</span></td>
<td><span class="style16">
<select name="sendto">
<option value=" ">Haman </option>
<option value=" ">Liz </option>
<option value=" ">Kristen </option>
</select>
</span></td>
</tr>
<tr><td><span class="style16"><font color=red>*</font> Name:</span></td>
<td><input name="Name" size=25></td>
</tr>
<tr><td><span class="style16"><font color=red>*</font> Email:</span></td>
<td><input name="Email" size=25></td>
</tr>
<tr>
<td><span class="style17 style33"><strong>Company:</strong></span></td>
<td><input name="Company" size=25></td>
</tr>
<tr>
<td><span class="style17 style33"><strong>Phone:</strong></span></td>
<td><input name="Phone" size=25></td>
</tr>
<tr><td><span class="style17 style33"><strong>Subscribe to<br>
mailing list:</strong></span></td>
<td><span class="style16">
<input type="radio" name="list" value="No">
No Thanks<br>
<input type="radio" name="list" value="Yes" checked>
Yes, keep me informed<br>
</span></td>
</tr>
<tr>
<td colspan=2><span class="style16"><font color=red>*</font> Message:</span></td>
</tr>
<tr>
<td colspan=2 align=left><span class="style17">
<textarea name="Message" rows=5 cols=35></textarea>
</span></td>
</tr>
<tr><td colspan=2 align=center><input type="submit" name="send" value="Submit"></td></tr>
<tr><td colspan=2 align=center><small>A <font color=red>*</font> indicates a field is required</small></td></tr>
</table>
</form>

script.php
<?php
$to = $_GET['sendto'] ;
$from = $_GET['Email'] ;
$name = $_GET['Name'] ;
$headers = "From: $from";
$subject = "Contact Form";
$message = $_GET['Message'] ;

$fields = array();
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_GET[$a]); }

$headers2 = "From: ";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";

if($message == '') {print "You have not entered the message, please go back and try again";}
else {
if($to == '') {print "You have not entered the contact person, please go back and try again";}
else {
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: thanku.html" );}
else
{print "We encountered an error sending your mail."; }
}
}
}
}
?>

tHANK you
waterloo is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-10-2008, 02:31 PM Re: Contact Form Help (Convert $_POST to $_GET?)
Extreme Talker

Posts: 177
Trades: 0
It's best to just use method="post" and use the $_POST command. Otherwise it clutters up the url bar and people can do malicious things with GET commands.
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 08-10-2008, 03:33 PM Re: Contact Form Help (Convert $_POST to $_GET?)
Novice Talker

Posts: 6
Name: Jeff Hunt
Trades: 0
In your php.ini theres a setting i forgot which it is, but it declares whether you use $_POST or the name of the input that your sending through with a dollar sign (IE: $Fname, $Lname).. Make sure your setting is set to the one that allows $_POST you'll have to do more research with it.

Shimmy
__________________
Win prizes by putting your pic up and letting people tag it!
Please login or register to view this content. Registration is FREE

ShimmyShine is offline
Reply With Quote
View Public Profile Visit ShimmyShine's homepage!
 
Old 08-10-2008, 04:53 PM Re: Contact Form Help (Convert $_POST to $_GET?)
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Quote:
Originally Posted by kbfirebreather View Post
It's best to just use method="post" and use the $_POST command. Otherwise it clutters up the url bar and people can do malicious things with GET commands.
Also the URL (including the get params) is limited to something like 256 charactures.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-11-2008, 03:55 AM Re: Contact Form Help (Convert $_POST to $_GET?)
Junior Talker

Posts: 2
Trades: 0
Just set the method="get" and use $_REQUEST instead of $_GET. Here $_REQUEST will get both "GET" and "POST" methods.
blognol is offline
Reply With Quote
View Public Profile
 
Old 12-28-2008, 10:25 PM Re: Contact Form Help (Convert $_POST to $_GET?)
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Try taking the spaces out..

PHP Code:
<?php
$to 
$_GET['sendto'];
$from $_GET['Email'];
$name $_GET['Name'];
$headers "From: $from";
$subject "Contact Form";
$message $_GET['Message'];
?>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 12-29-2008, 08:52 AM Re: Contact Form Help (Convert $_POST to $_GET?)
Extreme Talker

Posts: 246
Trades: 3
I believe the array assignment needs to use square brackets, not curly ones

PHP Code:
//doesn't work
//$fields = array();
//$fields{"Company"} = "Company";
//$fields{"Email"} = "Email";
//$fields{"Phone"} = "Phone";
//$fields{"list"} = "Mailing List";

//this should work
$fields = array();
$fields["Company"] = "Company";
$fields["Email"] = "Email";
$fields["Phone"] = "Phone";
$fields["list"] = "Mailing List"
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
CouponGuy is offline
Reply With Quote
View Public Profile
 
Old 01-02-2009, 11:34 AM Re: Contact Form Help (Convert $_POST to $_GET?)
anderswc's Avatar
Super Talker

Posts: 132
Name: Will Anderson
Location: Terre Haute, IN
Trades: 0
Quote:
Originally Posted by ShimmyShine View Post
In your php.ini theres a setting i forgot which it is, but it declares whether you use $_POST or the name of the input that your sending through with a dollar sign (IE: $Fname, $Lname).. Make sure your setting is set to the one that allows $_POST you'll have to do more research with it.

Shimmy
Would that be register_globals?

http://us2.php.net/register_globals
__________________
Will Anderson

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
anderswc is offline
Reply With Quote
View Public Profile Visit anderswc's homepage!
 
Reply     « Reply to Contact Form Help (Convert $_POST to $_GET?)
 

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.38355 seconds with 12 queries