Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $mysql_server = "*********"; //This is probably correct
- $mysql_username = "*********"; // Your MySQL username
- $mysql_password = "*********"; // Your MySQL Password
- $mysql_database = "*********"; // The name of your database
- $mysql_table = "*********"; // Your actual table to hold the data
- // Make a MySQL Connection no changes need to be made here
- $con = mysql_connect($mysql_server,$mysql_username,$mysql_password) or die('Can not connect to server');
- mysql_select_db($mysql_database) or die('Can not connect to database');
- /*
- Variables passed from URL - list them all here.
- */
- $f = $_GET['f'];
- $p_date = mysql_real_escape_string($_GET['date']);
- $p_snick = mysql_real_escape_string($_GET['snick']);
- $p_smail = mysql_real_escape_string($_GET['smail']);
- $p_tnick = mysql_real_escape_string($_GET['tnick']);
- $p_tmail = mysql_real_escape_string($_GET['tmail']);
- $p_message = mysql_real_escape_string($_GET['message']);
- //This function will save text to database
- function create_account($con, $mysql_table, $p_date, $p_snick, $p_smail, $p_tnick, $p_tmail,$p_message) //declare function Part between () is all the variables you will need for this function.
- {
- mysql_query("INSERT INTO $mysql_table (p_date, p_snick, p_smail, p_tnick, p_tmail, p_message) VALUES('$p_date','$p_snick','$p_smail','$p_tnick','$p_tmail','$p_message')")
- or die('0'); // Something went wrong
- echo "1"; //All is right with the world. YAY.
- mysql_close($con);
- }
- // This function is used for nothing more than testing that the script and database are working.
- function connection_test($con, $mysql_table, $p_snick)
- {
- $result = mysql_query("SELECT * FROM $mysql_table WHERE snick = '$p_snick' ");
- while($row = mysql_fetch_array($result))
- if ($row <= 0)
- {
- echo "Could not comunicate with database. Double check your settings and ask your web host for help.";
- }
- else
- {
- echo "Connection test was OK!";
- }
- }
- // This determines which function to call based on the $f parameter passed in the URL.
- switch($f)
- {
- case na: create_account($con, $mysql_table, $p_date, $p_snick, $p_smail, $p_tnick, $p_tmail,$p_message); break;
- case ts: connection_test($con, $mysql_table, $p_snick); break;
- case ct: echo"1";
- default: echo"error";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement