liamloveslearning Posted December 15, 2009 Share Posted December 15, 2009 Hi everyone, Im trying to create a subscription form which only needs to collect the users name and email, I cant understand mysql and so I was wondering is there a way I can host a .txt file which has its permissions set to 777 where the form can possibly write all the data to this? if anybody can point me in the right direction Id be really grateful, thanks Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted December 15, 2009 Author Share Posted December 15, 2009 I found this tutorial http://www.plus2net.com/articles/php_newsletter_script.php but on a lot of forums theres posts saying how crap the coding is, would you recommend it? Quote Link to comment Share on other sites More sharing options...
cags Posted December 15, 2009 Share Posted December 15, 2009 You can store the details in a flat file, but I'd recommend against it. If you wish to do much PHP programming language then working with some form of PHP is likely to be ultimately unavoidable so best to learn it sooner rather than later. Standard MySQL is really not that complicated, you should be able to pick up the basics in under an hour. If you use a visual editor to create the tables (PHPMyAdmin for example), the only lines your likely to need for your current task are... SELECT name, email FROM users INSERT INTO users(name,email) VALUES('$name', 'email') At it's most basic MySQL is fairly 'readable', I think for example that even somebody without any knowledge of it can look at the above two lines and have a fairly good idea of what they actually do. Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted December 15, 2009 Author Share Posted December 15, 2009 Thanks cags, I understand what you typed and I really should sit down and learn it soon, Ive just created a table and I get a warning in phpmyadmin saying I no index defined, Ive 2 rows in my table, name and email; am I required to define an index? Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted December 15, 2009 Author Share Posted December 15, 2009 nevermind Ive noticed a few things already wrong haha, Im going to try and learn it from the beginning instead of relying on tuts.. Quote Link to comment Share on other sites More sharing options...
cags Posted December 15, 2009 Share Posted December 15, 2009 Technically you don't have to have an index, but generally you would have a column called `id` or `user_id`, in case you needed to identify a particular row in your database uniquely. If you don't have a specific method for generating an id (as shops often do for stock codes etc), then you would normally set it to auto increment. Without an `id` column, there would be nothing stopping you adding multiple rows with the name 'John' and the email 'john@domain'. If you did so you would have no way of identifying them as individual rows. Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted December 15, 2009 Author Share Posted December 15, 2009 Ive managed to sort that out, with the auto increment too; may sound stupid but this says it cant connect to my database have you any idea why? <?php $con = mysql_connect("localhost","newsletter","mypassword"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $sql="INSERT INTO users (name, email) VALUES ('$_POST[name]','$_POST[email]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted December 15, 2009 Author Share Posted December 15, 2009 nevermind ive just noticed the my_db, topic solved! thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.