Streaming live at 10am (PST)

Form submission


#1

Hi I created my first webflow page recently and then exported it from testing on my home server I am trying to insert new users into my Data base but > if($SERVER['REQUESTMETHOD'] == 'POST'){ does not seem to be working for me at all. Is webflow responsible for this or is this my error which i do not think it is any more .

`<?php

include 'base.php';

//check if the form has been submitted
if($_SERVER['REQUEST_METHOD'] == 'POST'){

   $message = "wrong answer";
   echo "<script type='text/javascript'>alert('$message');</script>"; 

  $firstName = mysql_real_escape_string($_POST['firstName']);
  $lastName = mysql_real_escape_string($_POST['lastName']);
  $password = mysql_real_escape_string($_POST['sign-up-password']);
  $email = mysql_real_escape_string($_POST['email2']);

  $password = md5($password);

  $action = array();
  $action['result'] = null;

  //add to the database
  $add = mysql_query("INSERT INTO `users` VALUES(NULL,'$firstName','$lastName','$password','$email',0)");

           
  if($add){
   
  
      //the user was added to the database    
               
      //get the new user id
      $userid = mysql_insert_id();
                   
      //create a random key
      $key = $firstName . $email . date('mY');
      $key = md5($key);
                   
      //add confirm row
      $confirm = mysql_query("INSERT INTO `confirm` VALUES(NULL,'$userid','$key','$email')"); 
                   
      if($confirm){
                   
          //let's send the email
      }
  }else{
           
      $action['result'] = 'error';
      array_push($text,'User could not be added to the database. Reason: ' . mysql_error());
      
  }
}

?>

form id="signup" name="signup" action="" method="post"

`>

      <label for="First-name">First Name:</label>
      <input id="firstName" type="text" placeholder="Enter your first name" name="First-name" data-name="First name" required="required" class="w-input textfield">
      <label for="lastNameLb">Last Name:</label>
      <input id="lastName" type="text" placeholder="Enter your last name" name="last-name" data-name="last name" required="required" class="w-input textfield">
      <label for="Email-2">Email:</label>
      <input id="email2" type="email" placeholder="Enter your email" name="Email" data-name="Email" required="required" class="w-input textfield">
      <label for="sign-up-password">Password:</label>
      <input id="sign-up-password" type="password" placeholder="Enter your password" name="sign-up-password" data-name="sign up password" required="required" class="w-input">
      <label for="password-confirm">Confirm Password:</label>
      <input id="password-confirm" type="password" placeholder="Confirm your password" name="password-confirm" data-name="password confirm" required="required" class="w-input">
      <input type="submit" value="Submit" data-wait="Please wait..." name="signup" class="w-button sign-in-button margin-top">
    </form>`

#2

Hi @yawlhed91, thanks a lot for the post. Webflow does not support forms on external servers, however I am happy to look at the site link to see if I can help give some additional info.

Could you share the published link on the external site, where the form is? That way can tell what the html result code is when the form is posted to your script.

One thing I noticed in the form action, is that it is showing as action="" and in this field should go the url path to your PHP mail script.


#3