Hey guys,

I'm a total newbie with this PHP stuff but i'm stuck with my page that allows people to sign up to my mailing list. Every time you press the "Submit Query" button on the form it brings up the option to download the php file. Have been working on it for a while and can't figure it out, its really starting to bug me!

Anyway, here is the code, if you need any more info let me know:

HTML

<form action="mail.php" method="post">
Email: <input type="text" name="email" /> 
<input type="submit" />
</form>

PHP

<?php
include 'auth.php';
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

@mysql_select_db(test) or die( "Unable to select database");

$sql="INSERT INTO mail (email)
VALUES 
('$_POST[email]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con)
?>

It's probably something simple i'm overlooking, but all help is appreciated!

First off, you need to validate the user form contents. I have experienced the file forcing a download on xampp and mamp. My solution came to me when I checked the error log files. This might be a great place to start looking.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.