
spudly1987
Members-
Posts
61 -
Joined
-
Last visited
Everything posted by spudly1987
-
i don't see anywhere in the code that it states mysql address can you let me know what line it is?
-
I've just double checked the user name, password, host and everything its all correct
-
I had all this working on a localhost on my computer and everything was functional, the only thing i did was go to the website www.freehostingseu.com and created a free hosting domain. then i created the database so i know i have that working in the database manager in there software, and i used the same credentials in the insert.php file to connect to and its not connecting so i already have a database connection
-
i've done that already like 10 times
-
when you visit this link it is showing some errors http://omgtechnotes.me.pn/insert.php below is the code for it I removed my user name and password for security purposes. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <img src="http://omgtechhelp.com/wp/wp-content/themes/OMGTech/images/logo7small.jpg" /> <center> <h1><u>Notes For The Month Of August</u></h1> </center> <a href="http://www.omgtechnotes.me.pn/index.html"> <input type="button" value="New Entry" /> </a> <body> <?php //Protect against mysql_injection $customername = mysql_real_escape_string(trim($_POST["customername"])); $phonenumber = mysql_real_escape_string(trim($_POST["pnumber"])); $email = mysql_real_escape_string(trim($_POST["eaddy"])); $issue = mysql_real_escape_string(trim($_POST["issue"])); $result = mysql_real_escape_string(trim($_POST["results"])); $date = mysql_real_escape_string(trim($_POST["Date"])); //Now check form input(Validating the form). $errmsg_arr = array(); //Array to store validation errors $check_Error = false; //Validation error flag if (empty($customername)){ $errmsg_arr[]= '.Please Enter Your Name'; $check_Error = true; } if (empty($phonenumber)){ $errmsg_arr[]= '.Please Enter Your Phone Number'; $check_Error = true; } if (empty($email)){ $errmsg_arr[]= '.Please Enter Your Email'; $check_Error = true; } if (empty($issue)){ $errmsg_arr[]= '.Please what is your issue'; $check_Error = true; } if (empty($result)){ $errmsg_arr[]= '.Please what is your issue'; $check_Error = true; } if (empty($date)){ $errmsg_arr[]= '.Please what is your issue'; $check_Error = true; } //Printing out any error message stored in the array. if ($check_Error == true){ echo '<h1>ERROR: </h1><h3>Please check below for Error Details</h3>'; if( isset($errmsg_arr) && is_array($errmsg_arr) && count($errmsg_arr) > 0 ) { echo '<ul><font color="red">'; foreach($errmsg_arr as $msg) { echo '<li><b>Error: '.$msg.'</b></li><br />'; } echo '</font></ul>'; } //Please change the a href link to the name of your page. echo "<p><a href='http://www.omgtechnotes.me.pn/index.html'>Go Back To Register</a></p>"; } //After validating successfully else { /* Now we will write a query to insert user details into database */ $host = "fdb5.freehostingeu.com"; // Host name...change it to your configuration information. $username = ""; // Mysql username...change it to your configuration information. $password = ""; // Mysql password...change it to your configuration information. $db_name = "usernote"; // Database name...change it to your configuration information. // Connect to server mysql_connect("$host", "$username", "$password") or die('ERROR: Cannot connect' .mysql_error()); //connect to database mysql_select_db("$db_name") or die ('ERROR: Cannot connect'.mysql_error()); $tbl_name = "UserNote"; //Mysql Table name...change it to your configuration information. $sql="INSERT INTO $tbl_name (CustomerName, Phone, Email, Issue, Result, Date) VALUES('$customername', '$phonenumber', '$email', '$issue', '$result', '$date')"; } if (!mysql_query($sql)) //notice the "!" it means if the mysql_query($sql) cannot be executed, then die error. ELSE execute the mysql_querry($sql) to //insert into table in the database. { die('Error in Registration,: ' . mysql_error()); } else { //Insert User into the database. } ?> <hr/> <table border="1"> <tr> <th align="center">DATE</th> <th align="center">NAME </th> <th align="center">EMAIL </th> <th align="center">PHONE </th> <th align="center">ISSUE </th> <th align="center">RESULT </th> </tr> <?php $result=mysql_query("SELECT * FROM $tbl_name"); //sql query to call all the record available in database if ($result) { while ($fetch = mysql_fetch_assoc($result)) { //Using the WHILE - LOOP TO Display the whole recode in tabular form. echo '<tr>'; echo '<td>'.$fetch['Date'] .'</td>'; echo '<td>'.$fetch['CustomerName'] .'</td>'; echo '<td>'.$fetch['Email'] .'</td>'; echo '<td>'.$fetch['Phone'] .'</td>'; echo '<td>'.$fetch['Issue'] .'</td>'; echo '<td>'.$fetch['Result'] .'</td>'; echo '</tr>'; } } else { die ("ERROR: Could not fetch record : ".mysql_error()); } ?> </table> </body> </html>
-
okay i have everything i need to get things working for myself but need someone if at all possible to walk me through on how to recreate my database through this website if at all possible www.freehostingeu.com <?php $host = "localhost"; // Host name $username = ""; // Mysql username...please try and locate your mysql //configuration. i.e. your username and password. $password = ""; // Mysql password // Connect to server mysql_connect("$host", "$username", "$password") or die('ERROR: Cannot connect' .mysql_error()); mysql_query("CREATE DATABASE mydb"); //here is the newly added code..Selecting the database mysql_query("USE mydb"); $sql = mysql_query( "CREATE TABLE UserNote (CustomerName varchar(255), Phone varchar(255), Email varchar(150), Issue varchar(255), Result varchar(255))"); if ($sql) { echo "Database and table created succesfully"; } else { die ('ERROR: Cannot connect'.mysql_error()); } ?>
-
Below are listed all the files i am using this is my index. html code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> .labelclass{ float: left; width: 150px; } </style> </head> <body> <img src="http://omgtechhelp.com/wp/wp-content/themes/OMGTech/images/logo7small.jpg" /> <center> <h1><u>Notes For The Month Of August</u></h1> </center> <hr /> <form name="myform" action="insert.php" target="_blank" method="post"> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Customer Name: </span><input type="text" name="customername" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Phone Number: </span><input type="tel" name="pnumber" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">E-Mail Address: </span><input type="text" name="eaddy" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Issue: </span><input type="text" name="issue" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Results: </span><input type="text" name="results" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Date: </span><input type="date" name="Date" /><br /> <input type="submit" name="submit" value="submit" style="background-color:#F60" /> </body> </html> this is my insert.php code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <center> <h1><u>Notes For The Month Of August</u></h1> </center> <body> <?php //Protect against mysql_injection $customername = mysql_real_escape_string(trim($_POST["customername"])); $phonenumber = mysql_real_escape_string(trim($_POST["pnumber"])); $email = mysql_real_escape_string(trim($_POST["eaddy"])); $issue = mysql_real_escape_string(trim($_POST["issue"])); $result = mysql_real_escape_string(trim($_POST["results"])); $date = mysql_real_escape_string(trim($_POST["Date"])); //Now check form input(Validating the form). $errmsg_arr = array(); //Array to store validation errors $check_Error = false; //Validation error flag if (empty($customername)){ $errmsg_arr[]= '.Please Enter Your Name'; $check_Error = true; } if (empty($phonenumber)){ $errmsg_arr[]= '.Please Enter Your Phone Number'; $check_Error = true; } if (empty($email)){ $errmsg_arr[]= '.Please Enter Your Email'; $check_Error = true; } if (empty($issue)){ $errmsg_arr[]= '.Please what is your issue'; $check_Error = true; } if (empty($result)){ $errmsg_arr[]= '.Please what is your issue'; $check_Error = true; } if (empty($date)){ $errmsg_arr[]= '.Please what is your issue'; $check_Error = true; } //Printing out any error message stored in the array. if ($check_Error == true){ echo '<h1>ERROR: </h1><h3>Please check below for Error Details</h3>'; if( isset($errmsg_arr) && is_array($errmsg_arr) && count($errmsg_arr) > 0 ) { echo '<ul><font color="red">'; foreach($errmsg_arr as $msg) { echo '<li><b>Error: '.$msg.'</b></li><br />'; } echo '</font></ul>'; } //Please change the a href link to the name of your page. echo "<p><a href='http://localhost/site/practice5.html'>Go Back To Register</a></p>"; } //After validating successfully else { /* Now we will write a query to insert user details into database */ $host = "localhost"; // Host name...change it to your configuration information. $username = "root"; // Mysql username...change it to your configuration information. $password = ""; // Mysql password...change it to your configuration information. $db_name = "mydb"; // Database name...change it to your configuration information. // Connect to server mysql_connect("$host", "$username", "$password") or die('ERROR: Cannot connect' .mysql_error()); //connect to database mysql_select_db("$db_name") or die ('ERROR: Cannot connect'.mysql_error()); $tbl_name = "UserNote"; //Mysql Table name...change it to your configuration information. $sql="INSERT INTO $tbl_name (CustomerName, Phone, Email, Issue, Result, Date) VALUES($customername', '$phonenumber', '$email', '$issue', '$result', '$date')"; } if ( mysql_query($sql) ) //notice the "!" it means if the mysql_query($sql) cannot be executed, then die error. ELSE execute the mysql_querry($sql) to //insert into table in the database. { die('Error in Registration,: ' . mysql_error()); } else { //Insert User into the database. echo 'Customer Name: '. $customername . '<br />Phone Number: ' .$phonenumber . '<br />E-Mail Address: ' . $email; echo '<br />Issue:'. $issue . '<br />Results:' . $result . '<br />' . 'Date:' .$date . '<br />' ; } ?> </body> </html> this is my db_tb.php file <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $host = "localhost"; // Host name $username = "root"; // Mysql username...please try and locate your mysql //configuration. i.e. your username and password. $password = ""; // Mysql password // Connect to server mysql_connect("$host", "$username", "$password") or die('ERROR: Cannot connect' .mysql_error()); //here is the newly added code..Selecting the database mysql_query("USE mydb"); $sql = mysql_query( "CREATE TABLE UserNote (CustomerName varchar(255), Phone varchar(255), Email varchar(150), Issue varchar(255), Result varchar(255))"); if ($sql) { echo "Database and table created succesffully"; } else { die ('ERROR: Cannot connect'.mysql_error()); } ?> </body> </html>
-
Nope did not remove any coding what so ever i also have a 3rd file i'm working with labeled db_tb.php for my database which is created right, but for some reason the insert.php is the only causing issues.
-
I am using xampp to run the codes, i open my html by going through to http://localhost/site/ and then click on the index.html
-
Alright guys just a little more help, below are the three pages i'm currently working with, some of it seems to be working but i'm having issues with the insert.php page, at the bottom is the results i'm seeing just need someone to guide me to resolve. I am not getting any syntax errors at all, and all 3 files are under one folder This is labeled index.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> .labelclass{ float: left; width: 150px; } </style> </head> <body> <img src="http://omgtechhelp.com/wp/wp-content/themes/OMGTech/images/logo7small.jpg" /> <center> <h1><u>Notes For The Month Of August</u></h1> </center> <hr /> <form name="myform" action="insert.php" target="_blank" method="post"> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Customer Name: </span><input type="text" name="customername" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Phone Number: </span><input type="tel" name="pnumber" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">E-Mail Address: </span><input type="text" name="eaddy" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Issue: </span><input type="text" name="issue" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Results: </span><input type="text" name="results" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Date: </span><input type="date" name="Date" /><br /> <input type="submit" name="submit" value="submit" style="background-color:#F60" /> </body> </html> [/HTML] [HR] This is labeled db_tb.php [PHP] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $host = "localhost"; // Host name $username = "root"; // Mysql username...please try and locate your mysql //configuration. i.e. your username and password. $password = ""; // Mysql password // Connect to server mysql_connect("$host", "$username", "$password") or die('ERROR: Cannot connect' .mysql_error()); //here is the newly added code..Selecting the database mysql_query("USE mydb"); $sql = mysql_query( "CREATE TABLE UserNote (CustomerName varchar(255), Phone varchar(255), Email varchar(150), Issue varchar(255), Result varchar(255))"); if ($sql) { echo "Database and table created succesffully"; } else { die ('ERROR: Cannot connect'.mysql_error()); } ?> </body> </html> This is labeled insert.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <center> <h1><u>Notes For The Month Of August</u></h1> </center> <body> <?php //Protect against mysql_injection $customername = mysql_real_escape_string(trim($_POST["customername"])); $phonenumber = mysql_real_escape_string(trim($_POST["pnumber"])); $email = mysql_real_escape_string(trim($_POST["eaddy"])); $issue = mysql_real_escape_string(trim($_POST["issue"])); $result = mysql_real_escape_string(trim($_POST["results"])); $date = mysql_real_escape_string(trim($_POST["Date"])); //Now check form input(Validating the form). $errmsg_arr = array(); //Array to store validation errors $check_Error = false; //Validation error flag if (empty($customername)){ $errmsg_arr[]= '.Please Enter Your Name'; $check_Error = true; } if (empty($phonenumber)){ $errmsg_arr[]= '.Please Enter Your Phone Number'; $check_Error = true; } if (empty($email)){ $errmsg_arr[]= '.Please Enter Your Email'; $check_Error = true; } if (empty($issue)){ $errmsg_arr[]= '.Please what is your issue'; $check_Error = true; } if (empty($result)){ $errmsg_arr[]= '.Please what is your issue'; $check_Error = true; } if (empty($date)){ $errmsg_arr[]= '.Please what is your issue'; $check_Error = true; } //Printing out any error message stored in the array. if ($check_Error == true){ echo '<h1>ERROR: </h1><h3>Please check below for Error Details</h3>'; if( isset($errmsg_arr) && is_array($errmsg_arr) && count($errmsg_arr) > 0 ) { echo '<ul><font color="red">'; foreach($errmsg_arr as $msg) { echo '<li><b>Error: '.$msg.'</b></li><br />'; } echo '</font></ul>'; } //Please change the a href link to the name of your page. echo "<p><a href='http://localhost/site/practice5.html'>Go Back To Register</a></p>"; } //After validating successfully else { /* Now we will write a query to insert user details into database */ $host = "localhost"; // Host name...change it to your configuration information. $username = "root"; // Mysql username...change it to your configuration information. $password = ""; // Mysql password...change it to your configuration information. $db_name = "mydb"; // Database name...change it to your configuration information. // Connect to server mysql_connect("$host", "$username", "$password") or die('ERROR: Cannot connect' .mysql_error()); //connect to database mysql_select_db("$db_name") or die ('ERROR: Cannot connect'.mysql_error()); $tbl_name = "UserNote"; //Mysql Table name...change it to your configuration information. $sql="INSERT INTO $tbl_name (CustomerName, Phone, Email, Issue, Result, Date) VALUES($customername', '$phonenumber', '$email', '$issue', '$result', '$date')"; } if ( mysql_query($sql) ) //notice the "!" it means if the mysql_query($sql) cannot be executed, then die error. ELSE execute the mysql_querry($sql) to //insert into table in the database. { die('Error in Registration,: ' . mysql_error()); } else { //Insert User into the database. echo 'Customer Name: '. $customername . '<br />Phone Number: ' .$phonenumber . '<br />E-Mail Address: ' . $email; echo '<br />Issue:'. $issue . '<br />Results:' . $result . '<br />' . 'Date:' .$date . '<br />' ; } ?> </body> </html> This is the error that i am running into
-
Hey everyone I am a newbie looking for some good assistance and support. The Questions are at the bottom of the page. I am using Adobe Dreamweaver Cs6 & Xampp I have the following two codes written up HTML Code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> .labelclass{ float: left; width: 150px; } </style> </head> <body> <img src="http://omgtechhelp.com/wp/wp-content/themes/OMGTech/images/logo7small.jpg" /> <center> <h1><u>Notes For The Month Of August</u></h1> </center> <hr /> <form name="myform" action="http://localhost/site/results.php" target="_blank" method="post"> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Customer Name: </span><input type="text" name="name" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Phone Number: </span><input type="tel" name="pnumber" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">E-Mail Address: </span><input type="text" name="eaddy" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Issue: </span><input type="text" name="issue" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Results: </span><input type="text" name="results" /><br /> <span class="labelclass" style="font-family:'Comic Sans MS', cursive">Date: </span><input type="date" name="Date" /><br /> <input type="submit" name="submit" value="submit" style="background-color:#F60" /> </body> </html> PHP Code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php if($_POST["submit"]) { $customername = $_POST["name"]; $phonenumber = $_POST["pnumber"]; $email = $_POST["eaddy"]; $issue = $_POST["issue"]; $result = $_POST["results"]; $date = $_POST["Date"]; echo "Customer Name: $customername<br /> Phone Number: $phonenumber<br /> E-Mail Address: $email<br /> Issue: $issue<br /> Results: $result<br /> Date: $date<br />" ;} ?> </body> </html> There are Three things I would like to accomplish 1. when I click on the submit button i would like the data to be put into table format as such, which also means i need to know how to have the php saved every time so that the information doesnt get over written Customer 1 Customer 2 Customer 3 Customer 4 Customer 5 Customer 6 Customer 7 Customer 8 etc 2. I would like to be able to make the phone number field automatically convert in to (111) 111-1111 Format 3. for the result input field I want to know how to make it when i submit i can have it change to green for completed, or blue for shiftchange, or etc. Any assistance would be greatly appreciated, i am a quick learner but i do like to ask a lot of questions, if it is easier for you just to do the code that is okay for me, but if you do i would like for you to explain what you did and why so i can also learn Thank you in advanced.