Current location: Hot Scripts Forums » Programming Languages » PHP » E-Mail form / Send code on one page


E-Mail form / Send code on one page

Reply
  #1 (permalink)  
Old 02-07-04, 02:07 PM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
E-Mail form / Send code on one page

Hi,

I have the follow script, which has the form for the contact, and the sending part for the form. The page is called like modules.php?module=contact
But i want the sending part to be done when the variable is called, so the url would look like modules.php?module=contact&action=send

PHP Code:

$query mysql_query("select * from ".$prefix."_mail");

$settings mysql_fetch_array($query);

$query mysql_query("select name,email from ".$prefix."_admin_users");
$contacts mysql_fetch_array($query);

//do the form
echo "<div align=\"center\">You can use this form to contact us.</div>";
echo 
"<p></p>";
echo 
"<div align=\"center\">";
echo 
"<form name=\"contact\" method=\"post\" action=\"modules.php?module=contact&action=send\">";
echo 
"<p>Name:"
echo 
"<input name=\"name\" type=\"text\" id=\"name\">";
echo 
"</p>";
echo 
"<p>E-Mail:"
echo 
"<input name=\"email\" type=\"text\" id=\"email\">";
echo 
"</p>";
echo 
"<p>I want to contact:";
echo 
"<select name=\"people\" id=\"people\">";
echo 
"<option>- Select One -</option>";
echo 
"<option value=".$contacts['email'].">";
echo 
$contacts['name'];
echo 
"</option>";
echo 
"</select>";
echo 
"</p>";
echo 
"<p>Query:</p>";
echo 
"<p>"
echo 
"<textarea name=\"query\" cols=\"50\" rows=\"5\" id=\"query\"></textarea>";
echo 
"</p>";
echo 
"<input type=\"submit\" name=\"Submit\" value=\"Submit\">";
echo 
"</form>";
if(
$action $_GET['send'])
{
 
$name $_POST['name'];
 
$email $_POST['email'];
 
$query $_POST['query'];
 
$to $_POST['people'];
 
 
$subject $settings['subject'];
 
$from $email;
 
$content 'Name:'.$name.'\n'
           
.'E-Mail:'.$from.'\n'
           
.'Query:'.$query.'\n';
           
 
mail($to$subject$content$from);
 echo 
$settings['thankyou'];

What i have above doesnt work, so what do i have to do to this line
PHP Code:

 if($action $_GET['send']) 

to get it to do what i want to do.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 02-07-04, 10:09 PM
XxXoldsaltXxX XxXoldsaltXxX is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
You quite simply have to add another = to the existing =.

Like,
PHP Code:

if($action == $_GET['send']) 

What yours--
PHP Code:

if($action $_GET['send']) 

--did was, it set $action to whatever $_GET['send'] was, if it was nonzero, it set the if() to true, and if it was zero, it set the if() to false.

In case you don't get it:

PHP Code:

$action 1;

if (
$action) { //Yes, that is valid
echo 'This will be displayed';
return 
0;
}
else{
echo 
'This will not be displayed';
return 
0;

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 02-10-04, 01:41 PM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
It doesnt work

This is exactly what i have in the page.

PHP Code:

query mysql_query("select * from ".$prefix."_mail"); 

$settings mysql_fetch_array($query); 

$query mysql_query("select name,email from ".$prefix."_admin_users"); 
$contacts mysql_fetch_array($query); 

//do the form 
echo "<div align=\"center\">You can use this form to contact us.</div>"
echo 
"<p></p>"
echo 
"<div align=\"center\">"
echo 
"<form name=\"contact\" method=\"post\" action=\"modules.php?module=contact&action=send\">"
echo 
"<p>Name:"
echo 
"<input name=\"name\" type=\"text\" id=\"name\">"
echo 
"</p>"
echo 
"<p>E-Mail:"
echo 
"<input name=\"email\" type=\"text\" id=\"email\">"
echo 
"</p>"
echo 
"<p>I want to contact:"
echo 
"<select name=\"people\" id=\"people\">"
echo 
"<option>- Select One -</option>"
echo 
"<option value=".$contacts['email'].">"
echo 
$contacts['name']; 
echo 
"</option>"
echo 
"</select>"
echo 
"</p>"
echo 
"<p>Query:</p>"
echo 
"<p>"
echo 
"<textarea name=\"query\" cols=\"50\" rows=\"5\" id=\"query\"></textarea>"
echo 
"</p>"
echo 
"<input type=\"submit\" name=\"Submit\" value=\"Submit\">"
echo 
"</form>"

if(
$action == $_GET['send']) 

$name $_POST['name']; 
$email $_POST['email']; 
$query $_POST['query']; 
$to $_POST['people']; 

$subject $settings['subject']; 
$from $email
$content 'Name:'.$name.'\n' 
           
.'E-Mail:'.$from.'\n' 
           
.'Query:'.$query.'\n'
            
mail($to$subject$content$from); 
echo 
$settings['thankyou']; 

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 02-10-04, 03:52 PM
woyrz's Avatar
woyrz woyrz is offline
Newbie Coder
 
Join Date: Dec 2003
Location: montreal
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
if you want to go easy work with a hiddend field.

PHP Code:

query mysql_query("select * from ".$prefix."_mail"); 

$settings mysql_fetch_array($query); 

$query mysql_query("select name,email from ".$prefix."_admin_users"); 
$contacts mysql_fetch_array($query); 

if(
$_POST[send] != "action"  

//do the form 
echo "<div align=\"center\">You can use this form to contact us.</div>"
echo 
"<p></p>"
echo 
"<div align=\"center\">"
echo 
"<form name=\"contact\" method=\"post\" action=\"modules.php?module=contact&action=send\">"
echo 
"<p>Name:"
echo 
"<input name=\"name\" type=\"text\" id=\"name\">"
echo 
"</p>"
echo 
"<p>E-Mail:"
echo 
"<input name=\"email\" type=\"text\" id=\"email\">"
echo 
"</p>"
echo 
"<p>I want to contact:"
echo 
"<select name=\"people\" id=\"people\">"
echo 
"<option>- Select One -</option>"
echo 
"<option value=".$contacts['email'].">"
echo 
$contacts['name']; 
echo 
"</option>"
echo 
"</select>"
echo 
"</p>"
echo 
"<p>Query:</p>"
echo 
"<p>"
echo 
"<textarea name=\"query\" cols=\"50\" rows=\"5\" id=\"query\"></textarea>"
echo 
"</p>"
echo 
"<input type=\"submit\" name=\"Submit\" value=\"Submit\">"
echo 
"<input name="send" type="hidden" id="send" value="action">";
echo 
"</form>"
}
if(
$_POST[send] == "action"  

$name $_POST['name']; 
$email $_POST['email']; 
$query $_POST['query']; 
$to $_POST['people']; 

$subject $settings['subject']; 
$from $email
$content 'Name:'.$name.'\n' 
           
.'E-Mail:'.$from.'\n' 
           
.'Query:'.$query.'\n'
             
mail($to$subject$content$from); 
echo 
$settings['thankyou']; 

it's should work and it does'nt show to the user
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 02-11-04, 02:16 AM
nd2 nd2 is offline
Wannabe Coder
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
if($action == $_GET['send']) // will cause error if in debug mode, since $_GET['send'] is not in the url.

doesnt make since to me, shouldent it be
if($_GET['$action'] == 'send')

thats just going of the links you gave us.
__________________
IonCMS (Coming Soon.)
http://ioncms.com
--
Ncaster (Free php/mysql cms)
http://ncaster.cjb.net
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classified Ads skipper23 Perl 3 11-22-05 03:22 AM
formmail problem gscraper Perl 12 08-27-04 04:06 AM
Classified Ads skipper23 Perl 2 12-30-03 04:43 AM
cannot send variable to new page (code included) brucewestfall Script Requests 2 12-19-03 12:32 AM
asp: URGENT! need to change code to create new form per id seala ASP 2 09-09-03 10:54 PM


All times are GMT -5. The time now is 07:04 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.