Contact Form

Hello, dear connoisseurs and lovers. There is a feedback form consisting of:

  • “Name:”
  • “Address:”
  • “Problem:”
  • Two buttons “call master” and “call appraiser”

In general, the bottom line is that when the admin clicks on the button, for example, “call the wizard”, the subject (or in the letter itself) should receive a notification that the wizard has been called. Is it even possible to do this?!

<form  action="send.php" method="post" >
<p><input type="text" name="name" size="35" id="name" value="" onfocus="if (this.value=='') this.value='';" onblur="if (this.value=='') this.value='';"/></p>
<p><input type="text" name="adres" size="35" id="adres" value="" onfocus="if (this.value=='') this.value='';" onblur="if (this.value=='') this.value='';"/></p>
<p><input type="text" name="problema" size="35" id="problema" value="" onfocus="if (this.value=='') this.value='';" onblur="if (this.value=='') this.value='';"/></p>
<input type="submit" value=" "><input type="submit" value=" ">
</form>

And the handler itself:

<?php
if (isset($_POST['name'])) {$name = $_POST['name'];}
if (isset($_POST['adres'])) {$adres = $_POST['adres'];}
if (isset($_POST['problema'])) {$problema = $_POST['problema'];}
$address = "[email protected]";
$sub = "-";
$mes = ": $name \n: $adres \n: \n$problema";
$send = mail ($address,$sub,$mes,"Content-type:text/plain; charset = utf-8\r\nFrom:$email");
if ($send == 'true')
{
echo " !";
}
else 
{
echo "  !";
}
?>

Do not judge strictly)


Answer 1, authority 100%

If without going into details, then in the form we change to:

<input type="submit" name="master" value=" "><input name="rater" type="submit" value=" ">

And add something like this to RNRku:

if (isset($_POST['master']))
    @mail ("[email protected]",$sub,$mes,"Content-type:text/plain; charset = utf-8rnFrom:$email");

Answer 2

I suggest doing this through a switch case construct, i.e. if the call to the wizard is pressed, then the value 1 is passed in the $type variable; if you pressed the call of the evaluator, then the value 2 is passed in the $type variable.

switch($type) { 
    case 1:
          ,  
    break;
    case 2:
          ,  
    break;
}

Answer 3

I did it like this

<?
$admin_email="[email protected]";
    $name = $_GET["name"];
    $email = $_GET["email"];   
    $comment = $_GET["comment"];
echo "<form method=get action=".$_SERVER['SCRIPT_NAME']." ><table>\n";
echo "<tr><td class=\"bottom\">Name:</td><td><input type=\"text\" name=\"name\" value=\"$name\" /></td></tr>\n";
echo "<tr><td class=\"bottom\">E-mail:</td><td><input type=\"text\" name=\"email\" value=\"$email\" /></td></tr>\n";
echo "<tr><td valign=\"top\" class=\"bottom\">Comment:</td><td><textarea name=\"comment\" value=\"$comment\" rows=\"8\" cols=\"40\" /></textarea></td></tr>\n";
echo "<tr><td colspan=\"2\"><input type=\"submit\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
    $title = "e-mail from user";
    $comment = str_replace("&quot;","\"",$comment);   
    $comment = stripslashes($comment);
    $comment = str_replace("<br>","\n",$comment);
    $content = "The addition from $name :\n".
                "IP : ".$_SERVER["REMOTE_ADDR"]."\n".
                "Date & time : ".$today = date("Y-m-d H:i:s")."\n".
               "----------------------------\n\n".
               $comment.
               "\n\n-----End Message-----";
    @mail($admin_email,$title,$content,"From: $email\n");
?>