Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

form email: control to send an email

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

form email: control to send an email

Postby bobrock4 » Tue Sep 25, 2012 12:49 pm

Hi all,

in this form email I have inserted a botton radio.

Code: Select all
Autorizzo&nbsp;  <input name="privacy_si" type="radio" value="autorizzo" checked=""> &nbsp;
Non autorizzo <input type="radio" name="privacy_si" value="non autorizzo">
                     


I need to make that, in case of input value"non autorizzo", it doesn't send the email and it writes on the page a text to explain why.

Thanks a lot to anyone will reply.

Ciao
Bob
bobrock4
New php-forum User
New php-forum User
 
Posts: 4
Joined: Mon Sep 24, 2012 12:03 am

Re: form email: control to send an email

Postby kyle04 » Tue Sep 25, 2012 2:43 pm

Presuming you are using the form post method :

Code: Select all
<form method=POST action="myscript.php">
Autorizzo&nbsp;  <input name="privacy_si" type="radio" value="autorizzo" checked=""> &nbsp;
Non autorizzo <input type="radio" name="privacy_si" value="non autorizzo">
<input type=submit name="submit">
</form>


myscript.php :


<?

if(isset($_POST['submit'])) {
$privacy = $_POST['privacy_si'];

if($privacy=="autorizzo") {

// do email stuff
}

else {

echo "your privacy message here";

}
} // if
?>
kyle04
New php-forum User
New php-forum User
 
Posts: 94
Joined: Sat Jul 07, 2012 1:36 pm

Re: form email: control to send an email

Postby bobrock4 » Wed Sep 26, 2012 12:38 am

Hi kyle,

many thanks for your reply. I have tried but I doesn't work. I have tried to put you code in myscript.php in the following way. In that script I have some controls as

Code: Select all
if ($messaggio == null)
{
print "Errore: &egrave; necessario compilare il campo 'Messaggio'";
}
else
// other controls
else
{
// email configuration


I have put a opposite version of your code between these controls in this way

Code: Select all
//other controls before
if(isset($_POST['submit'])) {
$privacy = $_POST['privacy_si'];

if($privacy=="non_autorizzo") {

echo "your privacy message here";

}
else
{
//email configuration


but it doesn't work.

Have you an idea about reasons why?

Thanks and ciao
bobrock4
New php-forum User
New php-forum User
 
Posts: 4
Joined: Mon Sep 24, 2012 12:03 am


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.