Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Check whether the form has been submitted
- if (array_key_exists('check_submit', $_POST)) {
- //Converts the new line characters (\n) in the text area into HTML line breaks (the <br /> tag)
- //$_POST['Comments'] = nl2br($_POST['Comments']);
- //Check whether a $_GET['Languages'] is set
- if ( isset($_POST['Colors']) ) {
- $_POST['Colors'] = implode(', ', $_POST['Colors']); //Converts an array into a single string
- }
- //Let's now print out the received values in the browser
- echo "Your name: {$_POST['Name']}<br />";
- echo "Your password: {$_POST['Password']}<br />";
- echo "Your favourite season: {$_POST['Seasons']}<br /><br />";
- echo "Your comments:<br />{$_POST['Comments']}<br /><br />";
- echo "You are from: {$_POST['Country']}<br />";
- echo "Colors you chose: {$_POST['Colors']}<br />";
- } else {
- echo "You can't see this page without submitting the form.";
- }
- $Name = $_POST['Name'];
- $Password = $_POST['Password'];
- $Seasons = $_POST['Seasons'];
- $Comments = $_POST['Comments'];
- $Country = $_POST['Country'];
- $Colors = $_POST['Colors'];
- # Database information-------------------------------------------
- # Trying to fetch data from database-----------------------------
- $myServer = "localhost";
- $myUser = "root";
- $myPass = "";
- $myDB = "group";
- //connection to the database
- $dbhandle = mysql_connect($myServer, $myUser, $myPass) //echo " connection to DB is OK ";
- or die("Couldn't connect to SQL Server on $myServer");
- //select a database to work with
- $selected = mysql_select_db($myDB, $dbhandle) //echo " DB Access is OK ";
- or die("Couldn't open database $myDB");
- echo "Your Name is : $Name </br>Password is : $Password </br>Chosen Season is : $Seasons </br>Put Comment is : $Comments </br>you are form : $Country </br> Chosen Colour is : $Colors </br>";
- $query = "INSERT INTO info (Id, Name, Password, Seasons, Comments, Country, Colors) VALUES ('NULL', $Name, $Password, $Seasons, $Comments, $Country, $Colors)";
- //execute the SQL query and return records
- $result = mysql_query($query) or die('Failed to write to Database');
- /* $numRows = mysql_num_rows($result);
- echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
- //display the results
- while($row = mysql_fetch_array($result))
- {
- echo "<li>" . $row["id"] . $row["name"] . $row["salary"] . $row["experience"] . "</li>";
- }
- */
- mysql_close($dbhandle);
- ?>
Add Comment
Please, Sign In to add comment