I am trying to create a mailing list / Ezine program....Is this is how I want it to work.
1. User Goes to my website and types in there Name and Email
2. Php adds that information to mySQL Database
3. I access mySQL databse with my vb.net program. Hopefully accessing some CSV file
4. My program reads the CSV file and adds the e-mails into a format friendly method and Client types e-mail and sends
5. In the e-mail it has a link to delete there username
------
I am having some trouble (since I have not used php before) putting it on the website.
This is my code
Code: Select all
<?php
//Login Information
$hostname="My_Hostname";
$username="My_Username";
$password="My_Password";
$dbname="My_DatabaseName";
//Connect to MySQL Database
mysql_connect($hostname,$username, $password) OR DIE ("Unable to connect to database! Please try again later.");
mysql_select_db($dbname);
//Open The Data
$fp = fopen ("./data.csv", "wb");
// MySQL Queries
$query = "SELECT * FROM Users order by Name";
$result = mysql_query($query);
// Coloums
$columns = "Name,E-Mail\n";
fwrite ($fp, $colums);
// MySQL Array
if ($result) {
while ($r = mysql_fetch_array($result)) {
$Name = $r["Name"];
$Email = $r["Email"];
### Rows ###
$data = "$Name,$Email\n";
fwrite ($fp, $data);
}
echo "A CSV file has been created.";
} else {
echo "No data. There maybe an error in the database.";
}
fclose($fp);
mysql_free_result($result)
?>That is all fine and dandy, but I don't know how to like put it on my webpage. Should I copy all of that and paste it directly onto the HTML Body? (wouldn't that explose my pass and everything) I know were the Variables Name and Email are comming from....my form, but how do I have my form on submit catch my php code? And where will this "./data.csv" Be stored? Can I access it VIA ftp? Thanks a Ton!