Page 1 of 1

a function return + variable to exit

Posted: Tue Mar 28, 2006 2:56 am
by NAT
Hi,


I made a simple mailform script, where users can send email to me. Now i want to make a message, so when they submit the form that the form desapears and they get a message <span style='color:red;text-decoration:blink' title='Alert a moderator!'>grilled spam</span>:

echo "Your mail has been submited" . So that they only c the text message "Your mail is submited" .

I know it must be done with some function and with combination of a variable :? but i am not shote of it.


Can anyone explain how can i do this?


Thanks in advance,

NAT

Posted: Tue Mar 28, 2006 3:17 am
by s.dot

Code: Select all

<?php
if(!empty($_POST)){
   //  send email
   echo "Your email message has been submitted.";
} ELSE {
   echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
   // rest of form here
}
?>

Posted: Tue Mar 28, 2006 3:48 am
by NAT
But there is also other way. I think with function return and then you have to make a variable wich listens to that function, foreaxample like this:

$thisvariable = $resturn; $i

//herecomes a form

echo "your post is submitted"

echo = $thisvariable


:? :? :? :? :? is this possible?

Posted: Tue Mar 28, 2006 1:03 pm
by NAT
I tryd this code, but the form is not desapearing. it gives the message after submitting the form "you remail has been submited" but the form is not desapearing. :(

Posted: Tue Mar 28, 2006 1:10 pm
by feyd
did you put the form inside the "else" block?

Posted: Thu Mar 30, 2006 1:06 pm
by NAT
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Sry for late answer, i have almost no time after work     

But this how i wrote the script and add it also the one that posted [b]scottay[/b]

Code: Select all

<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">
<strong>				
Name:</strong>&nbsp;
			
<input type="text" name="sender_name" style="width:150px; height:17px; font-family:Tahoma; font-size:10px; border-width:1px; border-style:solid; border-color:#667079  ">
<br><img src="images/spacer.gif" height="5px"><br>
<strong>	
Email:</strong>&nbsp;
<input type="text" name="sender_email" style="width:150px; height:17px; font-family:Tahoma; font-size:10px; border-width:1px; border-style:solid; border-color:#667079  ">
<br><img src="images/spacer.gif" height="5px"><br>
<strong>
Message:
</strong>	
<br><img src="images/spacer.gif" height="3px"><br>
<textarea name="message" style="width:320px; height:120px; font-family:Tahoma; overflow:auto; font-size:10px; border-width:1px; border-style:solid; border-color:#667079;  "></textarea>
<div style="padding-top:5px;padding-right:45px " align="center"><input type="image" src="images/submit.jpg"> </div>

</form>


</TD>
</TABLE>

<?php 
if(!empty($_POST)){ 

echo "Your email message has been submitted."; 

} else { 

echo "<form action=\"{$_SERVER['PHP_POST']}\" method=\"post\">"; 

} 


$msg = "E-MAIL WAS SEND FROM WEBSITE\n";

$msg .= "E-Mail:\t$_POST[sender_email]\n";

$msg .= "Message:\t$_POST[message]\n";
$to = "xxxxx@xxxx.com";
$subject = "Web Site Feedback";
$mailheaders .= "Reply-To: $_POST[sender_email]\n";
$mailsend = mail($to, $subject, $msg, $mailheaders);


?>

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Mar 30, 2006 1:12 pm
by Nathaniel
No, you want something like this:

Code: Select all

<?php 
if(!empty($_POST)){ 

echo "Your email message has been submitted."; 

$msg = "E-MAIL WAS SEND FROM WEBSITE\n";
$msg .= "E-Mail:\t$_POST[sender_email]\n";
$msg .= "Message:\t$_POST[message]\n";

$to = "xxxxx@xxxx.com";
$subject = "Web Site Feedback";
$mailheaders = "Reply-To: $_POST[sender_email]\n";
$mailsend = mail($to, $subject, $msg, $mailheaders);

} else { 
?>
<form action="{$_SERVER['PHP_SELF']}\" method=\"post\">
<strong>                
Name:</strong>&nbsp;
            
<input type="text" name="sender_name" style="width:150px; height:17px; font-family:Tahoma; font-size:10px; border-width:1px; border-style:solid; border-color:#667079  ">
<br><img src="images/spacer.gif" height="5px"><br>
<strong>    
Email:</strong>&nbsp;
<input type="text" name="sender_email" style="width:150px; height:17px; font-family:Tahoma; font-size:10px; border-width:1px; border-style:solid; border-color:#667079  ">
<br><img src="images/spacer.gif" height="5px"><br>
<strong>
Message:
</strong>    
<br><img src="images/spacer.gif" height="3px"><br>
<textarea name="message" style="width:320px; height:120px; font-family:Tahoma; overflow:auto; font-size:10px; border-width:1px; border-style:solid; border-color:#667079;  "></textarea>
<div style="padding-top:5px;padding-right:45px " align="center"><input type="image" src="images/submit.jpg"> </div>

</form> 
<?PHP
}
?>

Posted: Fri Mar 31, 2006 2:56 pm
by NAT
Yep that works, thanks.