1
    <!--This is the html form code--> 
        <div class="modal-body">
            <form id="modal-form" accept-charset="UTF-8" method="POST" action="signUp.php" data-remote="true" >
                      <p><label for="firstName"><small>First Name:</small></label><br />
                      <input type="text" id="firstName" name="firstName" required="required" /></p><br />
                      <p><label for ="lastName"><small>Last Name:</small></label><br />
                      <input type="text" id="lastName" name="lastName" required="required" /></p><br />
                      <p><label for="email"><small>Email: </small></label><br />
                      <input type="email" name="email" required="required"/></p><br />
                <input id="modal-form-submit" type="submit" name="submit" class="btn btn-success"/>
            </form>

`

<?php
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$email = $_POST['email'];

require("includes/config.php");
require("includes/connect.php");

if(isset($_POST['submit'])){

$query="INSERT INTO mb_emaillist (ID, firstName, lastName, email) VALUES (null, '$firstName', '$lastName', '$email')";
$result=mysqli_query($db, $query);

    if(!$result)
        die("SELECT error: " .mysqli_error($db));
    if($result){
        print"Thank you $firstName $lastName for signing up with MyBrunch!";
    }
}

mysqli_close($db);

?>`

I am looking to get a success message delivered in a modal after my form was successfully sent to my database. Right now the information is sent but, nothing happens.

  • [Your script is at risk for SQL Injection Attacks.](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php). If you want a success message delivered to your modal look into AJAX. – Jay Blanchard Oct 16 '15 at 18:28
  • you want success message in modal itself. ? submit query is present in your modal code. – Nana Partykar Oct 16 '15 at 18:35
  • @NanaPartykar I am looking for a success message to appear in the same modal after clicking submit. I feel that Jay Blanchard has some good advice for building an onClick function to display that message. But what happens when you click on the submit button, and the fields aren't filled out? Thank you. – learningTheBasics Oct 16 '15 at 18:44

1 Answers1

0

Wow, just pick a PHP Framework! Don't work like this even for a small project. Among so many options, I recommend Laravel... Pick the 4.2 release, it's the simplest!

BTW: Your print call at line 16, lack of parenthesis.

Adon
  • 1
  • 1