0

this is my form code :

 <form name="input" action="index.php" method="post">
 <input type="text" name="email" id="email" value="Subscribe to Our News" onclick="value=''"/>
 <input type="submit" value="Sign up" id="submit"/>
 </form>

This is my post event code in the same page index.php

 if (isset($_POST['submit']))
{
    $email = $_POST['email'];
    echo $email;
    $sql = mysql_query("INSERT INTO subscribe (email) VALUES ('$email')");

    if($sql){
        echo 'True';
    }else{
        echo 'false';
    }
}

I don't get the reply back from the click event! pls help me!

Imesh Chandrasiri
  • 5,558
  • 15
  • 60
  • 103
  • You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). You are also **vulnerable to [SQL injection attacks](http://bobby-tables.com/)** that a modern API would make it easier to [defend](http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php) yourself from. – Quentin Nov 28 '12 at 16:57

1 Answers1

4

You need to give your submit button a name, in order to check if it was pressed:

<input type="submit" value="Sign up" id="submit" name="submit"/>
moonwave99
  • 21,957
  • 3
  • 43
  • 64