Jump to content

AlexRares

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by AlexRares

  1. Salut! De curand am lucrat la un sistem de contact prin email folosind PHP si HTML. Singura problema pe care nu stiu cum sa o rezolv este atunci cand de exemplu gresesc ceva in completarea cererii si cand primesc eroarea (pop-up in browser) ma da pe pagina .php, nu inapoi in Index. Va rog ajutati-ma, multumesc! <?php $myemail = ""; $yourname = check_input($_POST['yourname'], "Enter your name"); $subject = check_input($_POST['subject'], "Write a subject"); $email = check_input($_POST['email']); $likeit = check_input($_POST['likeit']); $how_find = check_input($_POST['how']); $comments = check_input($_POST['comments'], "Write your comments"); if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) { echo "<script type='text/javascript'>alert('Adresa de e-mail nu este valida!');</script>"; die(); } $message = "Sugestie/Cerere: Nume: $yourname E-mail: $email Cum ne-a gasit: $how_find Mesaj: $comments"; mail($myemail, $subject, $message); header('Location: mail2.html'); exit(); function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { ?> <html> <body> <b>Te rog corecteaza erroarea urmatoare:</b><br /> <?php echo $myError; ?> </body> </html> <?php exit(); } ?> <form action="mail.php" method="post"> <p><b>Numele tau:</b> <input type="text" name="yourname" /></b> <b>Subiect:</b> <input type="text" name="subject" /></b> <b>E-mail:</b> <input type="text" name="email" /></b> <b>Cum ne-ai gasit?:</b> <select name="how"> <option value=""> -- Alege o varianta -- </option> <option>Google</option> <option>Yahoo</option> <option>Prieteni</option> <option>Alta modalitate</option> </select> <b>Mesaj:</b> <textarea name="comments" rows="6" cols="40"></textarea></p> <p><input type="submit" value="Trimite"></p> </form> P.S.: In cazul in care cererea a functionat am pus header-ul care functioneaza, dar daca il pun pentru greseli nu merge.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.