Jump to content

Wrong functioning link in php


willH

Recommended Posts

Hello,
In php i'm not much had knowledge of the, English also not very good, thank you for understanding.
I have problems with this form, Can not preview the form. Appears link after sending.
I need to so as to display Form. After sending completed form redirect to this page and vice versa.
My script:
 
<?php
   
   $titleErr = $nameErr = $emailErr = $commentErr = "";
   $title = $name = $email = $comment = "";
   
   if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (empty($_POST["title"])) {
        $titleErr = "You must enter Title!";
     } else {
       $title = test_input($_POST["title"]);
     }
     
     if (empty($_POST["name"])) {
       $nameErr = "Must enter the Name!";
     } else {
       $name = test_input($_POST["name"]);
     
       if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
         $nameErr = "Only letters and white space allowed";
       }
     }
     
     if (empty($_POST["email"])) {
       $emailErr = "Must enter the name Email!";
     } else {
       $email = test_input($_POST["email"]);
     
       if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         $emailErr = "Invalid email format";
       }
     }     
  
     if (empty($_POST["comment"])) {
       $commentErr = "Must enter the name comment";
     } else {
       $comment = test_input($_POST["comment"]);
       
       if (!preg_match("/^[a-zA-Z ]*$/",$comment)) {
         $commentErr = "Only letters and white space allowed";
       }
     }
  }
  
  //  Check error messages, if none, then send email...
  if ($titleErr=="" AND $nameErr=="" AND $emailErr=="" AND $commentErr=="") {
      $to = "@..My email..";
      $from = $_POST['email'];
      $title = $_POST['title'];
      $name = $_POST['name'];
      $subject = "Info from";
      $subject2 = "Copy of your form submission";
      $comment = $title . " " . $name . " " . "\n\n" . $_POST['comment'];
      $comment2 = "Here is a copy of your comment " . $name . "\n\n" . $_POST['comment'];
  
      $headers = "From:" . $from;
      $headers2 = "From:" . $to;
      mail($to,$subject,$comment,$headers);
      mail($from,$subject2,$comment2,$headers2);
      header("Location: http://..My web../thanks.html"); 
      }
  
  function test_input($data) {
     $data = trim($data);
     $data = stripslashes($data);
     $data = htmlspecialchars($data);
     return $data;
  }
  
  ?>
<HTML> 
<head>


</head>
<body> 
  <form method="post" action="">
     <fieldset>
        <legend>Write us what you need to know</legend>
     <center><span class="error" style="font:13px Arial"><big> * </big> required field.</span></center>
     <br>
  
     Title: <input type="text" name="title" size="5" value="<?php echo $title;?>">
     <span class="error"><big> * </big><?php echo $titleErr;?></span><span id="example"> / Mr, Ms, ... / </span>
     <br><br>     
     Name: <input type="text" name="name" size="30" value="<?php echo $name;?>">
     <span class="error"><big> * </big> <?php echo $nameErr;?></span><span id="example"> / First Name and Last Name / </span>
     <br><br>
     E-mail: <input type="text" name="email" size="40" value="<?php echo $email;?>">
     <span class="error"><big> * </big> <?php echo $emailErr;?></span>
     <br><br>
     Comment:<span class="error" style="position:relative; top:2px;"><big> * </big></span>
              <br><br>
             <textarea name="comment" rows="7" cols="55"> <?php echo $comment;?></textarea>
             <span class="error"><?php echo $commentErr;?></span>
     <br>
    <div  id = "rocaptcha_placeholder" ></div>
      <script  type = "text/javascript"  src = "http://rocaptcha.com/api/js/?key=.....My key......" ></script>
      <script  type = "text/javascript" >
           RoCaptcha . init ( "rocaptcha_placeholder" );
      </script>
     <br>
    <input type="submit" name="submit" value="Submit" id="send">
 </form>
 
 
 </body>
 </html>

Díky všem za vaši pomoc!!! Will

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.