Simple PHP submit form not working

mildrenben picture mildrenben · Dec 31, 2013 · Viewed 38.2k times · Source

Just making a simple submit form and can't seem to get it working.

It won't even report errors which is odd.

Checked the php.ini and that all seems fine too.

HTML:

<form id="submit-form" action="receiving.php" method="POST">
        <h3>Submit a Link</h3>
        <fieldset>
            <table>
                <tr>
                    <td><label for="name">You</label></td>
                    <td><input id="name" name="name" type="text" placeholder="Your Twitter or Blog ect." /></td>
                </tr>
                <tr>
                    <td><label for="submit-links">Link(s)</label></td>
                    <td><input id="sumbit-links" name="submit-links" type="text" placeholder="" required="" /></td>
                </tr>
                <tr>
                    <td><input name="submit" type="submit" value="SUBMIT" /></td>
                </tr>
            </table>
        </fieldset>
    </form>

receiving.php:

<?php 
error_reporting(-1);
$name = $_POST['name']; 
$submit-links = $_POST['submit-links']; 
if(isset($_POST['submit'])){
 $from_add = "[email protected]"; 
 $to_add = "[email protected]"; 
 $subject = "Your Subject Name";

 $message = "Name:$name \n Sites: $submit-links";

 $headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion()

 if(mail($to_add,$subject,$message,$headers)){
    $msg = "Mail sent";
 } 
}
print "<p>Thanks $name</p>";
?>

Any help would be much appreciated :)

Answer

user1932079 picture user1932079 · Dec 31, 2013

$submit-links is not a valid variable name. Switch all instances to $submit_links