Home > Technical & Creative Skills > Programming, Servers & Scripts

How to save info to database? (7)


12-28-2011 08:29 AM #1 shanktank (Member)
How to save info to database?

I used to collect my opt-in form info using Aweber.
But now I want to save them to my database (MySQL?).

Are there any tutorials that teach this specifically?
I want it to save all the info collected on the form then redirect to the thank you page.


12-28-2011 08:33 AM #2 polarbacon (Moderator)

Why not just save it to a csv?

Do you need to re-access the data? If not I would just save it to a csv file....it makes it easier if your using your own mailer...


12-28-2011 09:09 AM #3 shanktank (Member)

Is it easier to save to csv?
Either way, I don't know how to do it.

DB stuff turns me off.

Not really looking to do mailing, but to verify data and check patterns.


12-29-2011 04:47 AM #4 shanktank (Member)

Anyone knows how to do this?


12-29-2011 11:47 AM #5 polarbacon (Moderator)

Quote Originally Posted by shanktank View Post
Anyone knows how to do this?
try this

send data from the form via GET...to data.php save the code below...as "data.php" and change the variables as needed

[PHP]
<?php
$fname = $_GET["fname"];
$lname = $_GET["lname"];
$email = $_GET["email"];
$phone = $_GET["phone"];
$zip = $_GET["zip"];

// format the data
$data = $fname . "\t" . $lname. "\t" . $email . "\t" . $zip . "\t" . $phone;

// write the data to the file
file_put_contents('/path/to/your/file.txt', $data, FILE_APPEND);

// send the user to the new page
header("Location: http://path/to/your/thankyou/page.html");
exit();
?>
[/PHP]


03-23-2012 03:51 AM #6 jayon (Member)

@Polar - might be a dumb question, but would you need to set permissions on that file.txt to avoid others from reading it?


03-23-2012 10:59 AM #7 brianb (Member)

Can't find the example I was using myself a while ago, but if you google "php mysql database tutorial/example" and similar terms, there are tons of walk-throughs online that will get you going...


Home > Technical & Creative Skills > Programming, Servers & Scripts