Jump to content

iVazanity

Members
  • Posts

    16
  • Joined

  • Last visited

Everything posted by iVazanity

  1. Thank you so much! You helped me alot! It works perfectly now!
  2. If you need the Webpage to test it out I can give you the Link to it.
  3. Wow thats very kind! Thanks But sadly, the E-Mail still doesn't arrive.
  4. EDIT: If the Captcha isn't used the mail won't be sent! Hooray! But if you use the captcha it doesn't send the email either.
  5. Alright fixed the error. Users still can send missages without using the captcha ://
  6. oh I see an error on line 186 gonna fix this
  7. Here we go: <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "mariail.com"; $email_subject = "Mario Business Contact"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['text'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['name']; // required $email_from = $_POST['email']; // required $text = $_POST['text']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(strlen($text) < 2) { $error_message .= 'The text you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Jemand hat dir eine Nachricht vom Kontaktformular von mario.samirafracasso.com gesendet\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Vorname, Nachname: ".clean_string($name)."\n"; $email_message .= "Email Adresse: ".clean_string($email_from)."\n"; $email_message .= "Nachricht: ".clean_string($text)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); //RECAPTCHA if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) { if( isset ( $_POST['g-recaptcha-response'] ) && ! empty ( $_POST['g-recaptcha-response'] ) ) { $key = '6Ld2RxATAAAAADPBKUF9YzNvGHJDSKEC1HtS8VIs'; $rip = 'http://mario.samirafracasso.com'; $captchaurl = 'https://www.google.com/recaptcha/api/siteverify?'; $captchaurl .= 'secret=' . $key . '&'; $captchaurl .= 'response=' . $_POST['g-recaptcha-response'] . '&'; $captchaurl .= 'ip=' . $rip; $curl_init = curl_init (); curl_setopt ( $curl_init, CURLOPT_URL, $captchaurl ); curl_setopt ( $curl_init, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $curl_init, CURLOPT_TIMEOUT, 5 ); curl_setopt ( $curl_init, CURLOPT_USERAGENT, 'PHP/reCAPTCHA' ); curl_setopt ( $curl_init, CURLOPT_SSL_VERIFYPEER, FALSE ); $response = curl_exec ( $curl_init ); if ( $response == FALSE ) { echo '<p>Curl Error: ' . curl_error ( $curl_init ); } else { $result = json_decode ( $response, TRUE ); if($result['success']) { if($result['success']) { mail($email_to, $email_subject, $email_message, $headers); } } curl_close ( $curl_init ); } } ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="../css/style.css"> <title>E-Mail versendet</title> </head> <body> <div id="mail-sent"> <h1>Thank you for contacting us. We will be in touch with you very soon.</h1> </div> </body> </html> <?php } ?> (Line 190)
  8. Alright I did that. Now it gives me the error Parse error: syntax error, unexpected end of file in /var/customers/webs/ni61032_1/mario/php/form_process.php on line 220 ...
  9. Hi, I did that as you said but the refreshing"bug" is still there.. heres the part of the code: { $result = json_decode ( $response, TRUE ); if($result['success']) { echo 'Recaptcha Result: '; var_dump ( $result['success'] ); } } Thank you so much for your help!
  10. Hello, I created a new form with reCaptcha and it works perfectly. My problem is, if a user fills out the form and forgets to use the captcha, the mail will be sent anyways..Whats the problem? Whats missing in my Code? Another problem is, if a user went to the processing page and refreshes this page the mail is sent a second time. That shouldn't be like that.. My HTML Code: <!DOCTYPE html> <html > <head> <meta charset="UTF-8"> <meta name="description" content="Kontaktieren Sie hier Mario Fracasso"> <meta name="keywords" content="contact,kontakt,mario,o,mario,schreiben,websites,offer"> <meta name="author" content="Mario"> <title>Contact - Mario</title> <link rel="stylesheet" href="css/style.css"> <script src='https://www.google.com/recaptcha/api.js'></script> </head> <body> <div id="form-main"> <div id="form-div"> <h1>Contact - Mario</h1> <hr> <form action="php/form_process.php" method="post" class="form" id="form1"> <p class="name"> <input name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] feedback-input" placeholder="First Name, Last Name" id="name" /> </p> <p class="email"> <input name="email" type="email" class="validate[required,custom[email]] feedback-input" id="email" placeholder="Email" /> </p> <p class="text"> <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="Message"></textarea> </p> <div class="g-recaptcha" data-sitekey="-------"></div> <p> <div class="submit"> <input type="submit" value="SEND" id="button-blue"/> <div class="ease"></div> </div> </form> <footer> <p>© Mario</p> </footer> </div> </div> </body> </html> The PHP Code (form-process.php): <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "mar@gmail.com"; $email_subject = "Mario Business Contact"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['text'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['name']; // required $email_from = $_POST['email']; // required $text = $_POST['text']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(strlen($text) < 2) { $error_message .= 'The text you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Jemand hat dir eine Nachricht vom Kontaktformular von mario.samirafracasso.com gesendet\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Vorname, Nachname: ".clean_string($name)."\n"; $email_message .= "Email Adresse: ".clean_string($email_from)."\n"; $email_message .= "Nachricht: ".clean_string($text)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); //RECAPTCHA if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) { if( isset ( $_POST['g-recaptcha-response'] ) && ! empty ( $_POST['g-recaptcha-response'] ) ) { $key = '6L1HtS8VIs'; $rip = 'htt'; $captchaurl = 'https://www.google.com/recaptcha/api/siteverify?'; $captchaurl .= 'secret=' . $key . '&'; $captchaurl .= 'response=' . $_POST['g-recaptcha-response'] . '&'; $captchaurl .= 'ip=' . $rip; $curl_init = curl_init (); curl_setopt ( $curl_init, CURLOPT_URL, $captchaurl ); curl_setopt ( $curl_init, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $curl_init, CURLOPT_TIMEOUT, 5 ); curl_setopt ( $curl_init, CURLOPT_USERAGENT, 'PHP/reCAPTCHA' ); curl_setopt ( $curl_init, CURLOPT_SSL_VERIFYPEER, FALSE ); $response = curl_exec ( $curl_init ); if ( $response == FALSE ) { echo '<p>Curl Error: ' . curl_error ( $curl_init ); } else { $result = json_decode ( $response, TRUE ); if($result['success']) { echo 'Recaptha Result: '; var_dump ( $result['success'] ); } } curl_close ( $curl_init ); } } ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="../css/style.css"> <title>E-Mail versendet</title> </head> <body> <div id="mail-sent"> <h1>Thank you for contacting us. We will be in touch with you very soon.</h1> </div> </body> </html> <?php } ?> Thanks in advance for your help.
  11. Thanks for your help. It was my fault. lol. It worked!
  12. It gets me another error in reCaptcha itself. Which is: ERROR: Invalid domain for site key I've set the right domain..I thought.
  13. Alright. Got ya. The error message is gone. what about this part? if($result['success']) { // YOUR CODE FOR SENDING THE EMAIL GOES HERE }
  14. Thank you for your answer! But if I paste this code into my Page, it gets me an error which is: Curl Error: ' . curl_error ( $curl_init ); } else { $result = json_decode ( $response, TRUE ); if($result['success']) { // YOUR CODE FOR SENDING THE EMAIL GOES HERE } } curl_close ( $curl_init ); } } What sending code for the email is supposed to be here? The Code: <!DOCTYPE html> <html > <head> <meta charset="UTF-8"> <meta name="description" content="Kontaktieren Sie hier Mario "> <meta name="keywords" content="contact,kontakt,mario,,schreiben,websites,offer"> <meta name="author" content="Mario"> <title>Contact - Mario</title> <link rel="stylesheet" href="css/style.css"> <script src='https://www.google.com/recaptcha/api.js'></script> </head> <body> <div id="form-main"> <div id="form-div"> <h1>Contact - Mario</h1> <hr> <form action="php/form_process.php" method="post" class="form" id="form1"> <p class="name"> <input name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] feedback-input" placeholder="First Name, Last Name" id="name" /> </p> <p class="email"> <input name="email" type="email" class="validate[required,custom[email]] feedback-input" id="email" placeholder="Email" /> </p> <p class="text"> <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="Message"></textarea> </p> <div class="g-recaptcha" data-sitekey="KEY"></div> <p> <div class="submit"> <input type="submit" value="SEND" id="button-blue"/> <div class="ease"></div> </div> </form> <footer> <p>© Mario</p> </footer> </div> </div> </body> </html> <?php if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) { if( isset ( $_POST['g-recaptcha-response'] ) && ! empty ( $_POST['g-recaptcha-response'] ) ) { $key = 'HEREISMYNORMALKEY'; $rip = $_SERVER['MYPAGE']; $captchaurl = 'https://www.google.com/recaptcha/api/siteverify?'; $captchaurl .= 'secret=HEREISMYSECRETKEY' . $key . '&'; $captchaurl .= 'response=https://www.google.com/recaptcha/api/siteverify' . $_POST['g-recaptcha-response'] . '&'; $captchaurl .= 'ip=https://www.google.com/recaptcha/api/siteverify' . $rip; $curl_init = curl_init (); curl_setopt ( $curl_init, CURLOPT_URL, $captchaurl ); curl_setopt ( $curl_init, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $curl_init, CURLOPT_TIMEOUT, 5 ); curl_setopt ( $curl_init, CURLOPT_USERAGENT, 'PHP/reCAPTCHA' ); curl_setopt ( $curl_init, CURLOPT_SSL_VERIFYPEER, FALSE ); $response = curl_exec ( $curl_init ); if ( $response == FALSE ) { echo '<p>Curl Error: ' . curl_error ( $curl_init ); } else { $result = json_decode ( $response, TRUE ); if($result['success']) { // YOUR CODE FOR SENDING THE EMAIL GOES HERE } } curl_close ( $curl_init ); } } <? What did I do wrong? And another question: Should I place this PHP code into my PHP file or just paste it into my html file? Thanks advance for your help!
  15. Hello im very new to PHP and I got a problem with integrating reCaptcha into my Form. Step one worked pretty good but im failing on Step 2 which is: If your users send the form with integrated reCAPTCHA, you will receive among other things, a string containing the name "G-recaptcha-response". If you want to find out if Google has verified the user in question, send a POST request with the following parameters: URL: https://www.google.c.../api/siteverify Secret (required) MY_SECRET_CODE Response (required) Value of 'g-recaptcha-response' remoteip The IP address of the end user Heres my HTML Code: <!DOCTYPE html> <html > <head> <meta charset="UTF-8"> <meta name="description" content="Kontaktieren Sie hier Mario Fracasso"> <meta name="keywords" content="contact,kontakt,mario,fracasso,mariofracasso,schreiben,websites,offer"> <meta name="author" content="Mario "> <title>Contact - Mario </title> <link rel="stylesheet" href="css/style.css"> <script src='https://www.google.com/recaptcha/api.js'></script> </head> <body> <div id="form-main"> <div id="form-div"> <h1>Contact - Mario </h1> <hr> <form action="php/form_process.php" method="post" class="form" id="form1"> <p class="name"> <input name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] feedback-input" placeholder="First Name, Last Name" id="name" /> </p> <p class="email"> <input name="email" type="email" class="validate[required,custom[email]] feedback-input" id="email" placeholder="Email" /> </p> <p class="text"> <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="Message"></textarea> </p> <div class="g-recaptcha" data-sitekey="MY_CODE"></div> <p> <div class="submit"> <input type="submit" value="SEND" id="button-blue"/> <div class="ease"></div> </div> </form> <footer> <p>© Mario</p> </footer> </div> </div> </body> </html> And heres my PHP Code: <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "MY-EMAIL"; $email_subject = "Your email subject line"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['text'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['name']; // required $email_from = $_POST['email']; // required $text = $_POST['text']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(strlen($text) < 2) { $error_message .= 'The text you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "text: ".clean_string($text)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> So, heres my question: How do I implement this reCaptcha? Is there any solution? I hope you can help me - oh and hey, im sorry for my bad english.
  16. Hello im very new to PHP and I got a problem with integrating reCaptcha into my Form. Step one worked pretty good but im failing on Step 2 which is: If your users send the form with integrated reCAPTCHA, you will receive among other things, a string containing the name "G-recaptcha-response". If you want to find out if Google has verified the user in question, send a POST request with the following parameters: URL: https://www.google.com/recaptcha/api/siteverify Secret (required) MY_SECRET_CODE Response (required) Value of 'g-recaptcha-response' remoteip The IP address of the end user Heres my HTML Code: <!DOCTYPE html> <html > <head> <meta charset="UTF-8"> <meta name="description" content="Kontaktieren Sie hier Mario Fracasso"> <meta name="keywords" content="contact,kontakt,mario,fracasso,mariofracasso,schreiben,websites,offer"> <meta name="author" content="Mario Fracasso"> <title>Contact - Mario Fracasso</title> <link rel="stylesheet" href="css/style.css"> <script src='https://www.google.com/recaptcha/api.js'></script> </head> <body> <div id="form-main"> <div id="form-div"> <h1>Contact - Mario Fracasso</h1> <hr> <form action="php/form_process.php" method="post" class="form" id="form1"> <p class="name"> <input name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] feedback-input" placeholder="First Name, Last Name" id="name" /> </p> <p class="email"> <input name="email" type="email" class="validate[required,custom[email]] feedback-input" id="email" placeholder="Email" /> </p> <p class="text"> <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="Message"></textarea> </p> <div class="g-recaptcha" data-sitekey="MYCODE"></div> <p> <div class="submit"> <input type="submit" value="SEND" id="button-blue"/> <div class="ease"></div> </div> </form> <footer> <p>© Mario Fracasso</p> </footer> </div> </div> </body> </html> And heres my PHP Code: <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "MY_EMAIL"; $email_subject = "Your email subject line"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['text'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['name']; // required $email_from = $_POST['email']; // required $text = $_POST['text']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(strlen($text) < 2) { $error_message .= 'The text you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "text: ".clean_string($text)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> So, heres my question: How do I implement this reCaptcha? Is there any solution? I hope you can help me - oh and hey, im sorry for my bad english.
×
×
  • 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.