Jump to content

G3NERALCHRIS

Members
  • Posts

    21
  • Joined

  • Last visited

G3NERALCHRIS's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. No idea what the problem was but I reinstalled Ubuntu on vmware and done all the steps again and it worked first time.
  2. I check the php.ini in terminal display errors is on by default and error reporting is E_ALL by default. Any suggestion?
  3. I have the complete website, and works fine on windows using XAMPP control panel accessing via localhost. Now I am having trouble accessing the table(s) via ubuntu after turning on mysql in ubuntu also I am receving no errors just a blank page. You can check the php but it might not make any difference. All assoicated files for linking with mysql are below if needed I will upload whole webiste without images. I have stopped mysql and restarted it, over and over again. Also tried using sudo /usr/sbin/mysqld --skip-grant-tables --skip networking & command and no luck. Website is running succesfully just mysql is not working any suggestion on what could be wrong. add-aboutme.php add-contactme.php add-guestbook.php delete-contact.php guestbook.php view-aboutme.php view-contactme.php view-guestbook.php
  4. I have created a add-login.php and add-reg.php. I'm trying to figure out why it doesn't say to my table in mysql. Add login below. <!DOCTYPE html> <html> <head> <title>Home Page</title> <style type="text/css"> @import url("templatemo_style.css"); </style> </head> <body> <div id="page"> <div id="logo"> </div> <html> <body> <p align="center"><a href="add-reg.php">Register</a>, or enter your user name and password:</p> <form action="index.html" method="post"> <p align="center"> Username: <input type = "text" name="User"><br> <p align="center"> Password: <input type = "password" name="Pass"><br> <br> </br> <input type="submit" value="Login"/> <input type="reset"> </form> </body> </html> </body> </html> add-reg.php <!DOCTYPE html> <html> <head> <title>Home Page</title> <style type="text/css"> @import url("templatemo_style.css"); </style> </head> <body> <div id="page"> <div id="logo"></div> <?php $host= "localhost"; $user = "root"; $passwd = ""; $database = "test"; $tbl_name = "PASS"; mysql_connect($host, $user, $passwd) or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); //This code runs if the form has been submitted if (isset($_POST['submit'])) { //This makes sure they did not leave any fields blank if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) { die('You did not complete all of the required fields, please go back, and complete the missing fields!'); } // checks if the username is in use if (!get_magic_quotes_gpc()) { $_POST['username'] = addslashes($_POST['username']); } $usercheck = $_POST['username']; $check = mysql_query("SELECT username FROM PASS WHERE username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { die('Sorry, the username '.$_POST['username'].' is already in use.'); } // this makes sure both passwords entered match if ($_POST['pass'] != $_POST['pass2']) { die('Your passwords did not match. '); } // here we encrypt the password and add slashes if needed $_POST['pass'] = md5($_POST['pass']); if (!get_magic_quotes_gpc()) { $_POST['pass'] = addslashes($_POST['pass']); $_POST['username'] = addslashes($_POST['username']); } // now we insert it into the database $insert = "INSERT INTO PASS (username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')"; $add_member = mysql_query($insert); ?> <h1>Registered</h1> <p>Thank you very much, you have registered - you may now <a href="add-login.php">login</a>.</p> <?php } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0"> <tr><td colspan=2><h1>Register to access the website.</h1></td></tr> <tr><td>Username:</td><td><br> <input type="text" name="username" maxlength="60"> </td></tr> <tr><td>Password:</td><td><br> <input type="password" name="pass" maxlength="10"> </td></tr> <tr><td>Confirm Password:</td><td><br> <input type="password" name="pass2" maxlength="10"> </td></tr> <tr><th colspan=0><input type="submit" name="submit" value="Register"></th></tr> </table> </form> <?php } ?>
  5. Thank you something so simple sometimes its hard to see these things.
  6. Notice: Undefined variable: row in C:\xampp\htdocs\hometown\hometown\view-contactme.php on line 14 I now get this error do I need to add on line 14 id into arrary? <?php $host= "localhost"; $user = "root"; $passwd = ""; $database = "test"; $tbl_name = "contactme"; mysql_connect ($host, $user, $passwd) or die("cannot connect server "); mysql_select_db( $database) or die("cannot select DB"); $result=mysql_query("SELECT * FROM $tbl_name"); while($rows = mysql_fetch_array($result)){ echo $rows['name'] . " " .$rows['email'] . " " . $rows['phoneno'] . " " . $rows['comments'] . "| <a href=\"delete-contact.php?id={$row['id']}\">Delete</a><br>"; // added delete link. The record id is being passed in the url } mysql_close(); //close database ?>
  7. Thank you for your help. Do you any suggestion on how you can delete a entire row from view-contactme.php? <?php $host= "localhost"; $user = "root"; $passwd = ""; $database = "test"; $tbl_name = "contactme"; mysql_connect ($host, $user, $passwd) or die("cannot connect server "); mysql_select_db( $database) or die("cannot select DB"); $result=mysql_query("SELECT * FROM $tbl_name"); while($rows = mysql_fetch_array($result)){ echo $rows['name'] . " " .$rows['email'] . " " . $rows['phoneno'] . " " . $rows['comments'] . "<br>"; } mysql_close(); //close database ?> So basically I was thinking something like. Link to a new php called delete.php and have a submit button on the bottom of the view-contactme.php. Example of delete is below. <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="contactme"; // Table name mysql_connect ("$host", "$username", "$password") or die ("cannot connect server "); mysql_select_db ("$db_name") or die ("cannot select DB"); // sql to delete a record $sql = "DELETE FROM guestbook WHERE name='chris'"; if ($conn->query($sql) === TRUE) { echo "Record deleted successfully"; } else { echo "Error deleting record: " . $conn->error; } $conn->close(); ?>
  8. Sorry I have put the code in that you previously gave me but get two errors. As stated above not sure what is wrong. I have the connection to the database from the start.
  9. where about do you want me to put this line in same if statement for example. // only run the query if the data is valid if($isValidData) { // use a prepared statement for inserting data into the table $stmt = $mysqli->prepare("INSERT INTO $tbl_name VALUES (?, ?, ?, ?)"); if(!$stmt) { trigger_error('Unable to prepare query: ' . $mysqli->error); } // bind the values to the query $stmt->bind_param('ssss', $name, $email, $phone, $comment);
  10. line 94 - $stmt->bind_param('ssss', $name, $email, $phone, $comment);
  11. Fatal error: Call to a member function bind_param() on a non-object in C:\xampp\htdocs\hometown\hometown\add-contactme.php on line 94 I have no idea what this fatal error means can you explain?
  12. All i get now is the following? Can you explain why? Please correct the following: Please enter your name Please enter your comment After adding a name, email, phoneno and comment it still comes up which that message why? I do understand why the if statement is their, but still don't understand why the error is occurring still. Unless its above the given char length which I doubt. I only put 'Chris' and 'Hello' in the comments.
  13. <!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>Contact Chris</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <!-- templatemo 301 blue ice --> <!-- Blue Ice Template http://www.templatemo.com/preview/templatemo_301_blue_ice --> <link href="templatemo_style.css" rel="stylesheet" type="text/css" /> </head> <body> <?php echo $result; ?> <div id="templatemo_wrapper"> <div id="templatemo_header"> <p><!-- end of site_title --> </p> <ul id="social_box"> <li><a href="https://www.facebook.com/christopher.deaton.399"><img src="images/facebook.png" alt="facebook" /></a></li> <li><a href="https://twitter.com/G3NERALCHRIS"><img src="images/twitter.png" alt="twitter" /></a></li> <li></li> <li></li> <li></li> </ul> </div> <!-- end of templatemo_header --> <div id="templatemo_menu"> <div class="home"><a href="index.html"></a></div> <ul> <li><a href="index.html">WHAT WE DO<span>Home</span></a></li> <li><a href="guestbook.php">Sign<span>Guestbook</span></a></li> <li><a href="about.html">WHO WE ARE<span>About Me</span></a></li> <li><a href="contact.html" class="last">ANY QUESTION?<span>Contact Me</span></a></li> </ul> </div> <!-- end of templatemo_menu --> <div id="templatemo_content_wrapper"> <div id="templatemo_content_top"></div> <div id="templatemo_content"> <h2>Contact Me!</h2> <p> </p> <div id="contact_form"> <h4>Quick Contact</h4> <form method="post" name="contact" action="#"> <div class="col_w340 float_l"> <label for="author">Name:</label> <input name="author" type="text" class="input_field" id="author" maxlength="40" /> <div class="cleaner_h10"></div> <label for="email">Email:</label> <input name="email" type="text" class="input_field" id="email" maxlength="40" /> <div class="cleaner_h10"></div> <label for="phone">Phone:</label> <input name="phone" type="text" class="input_field" id="phone" maxlength="40" /> <div class="cleaner_h10"></div> </div> <div class="col_w340 float_r"> <label for="text">Message:</label> <textarea id="text" name="text" rows="0" cols="0" class="required"></textarea> <div class="cleaner_h10"></div> <input name="submit" type="submit" class="submit_btn float_l" id="submit" formaction="add-contactme.php" value="Send" /> <input type="reset" class="submit_btn float_r" name="reset" id="reset" value="Reset" /> </div> </form> </div> <p> </p> <div class="cleaner"></div> </div> <div id="templatemo_content_bottom"></div> </div> <div id="templatemo_footer"></div> <!-- end of templatemo_footer --> </div> <!-- end of templatemo_wrapper --> </body> </html> <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="contactme"; // Table name mysql_connect ("$host", "$username", "$password") or die ("cannot connect server "); mysql_select_db ("$db_name") or die ("cannot select DB"); if (isset($_POST['author']) && ($_POST['author'] !='')){ // get data from post $name = $_POST["author"]; $email = $_POST["email"]; $phoneno = $_POST["phone"]; $comments = $_POST["text"]; $sql="INSERT INTO $tbl_name VALUES ('$name', '$email', '$phoneno''$comments')"; $result=mysql_query($sql); // echo result $result = $name - $email - $phoneno - $comments; } if($result){ echo "Successful" . "<BR>"; echo "<a href='view-contactme.php'>View Contact Me</a>"; // link to view contact me page } mysql_close(); ?> This last is to view whether it works or not. <?php $host= "localhost"; $user = "root"; $passwd = ""; $database = "test"; $tbl_name = "contactme"; mysql_connect ($host, $user, $passwd) or die("cannot connect server "); mysql_select_db( $database) or die("cannot select DB"); $result=mysql_query("SELECT * FROM $tbl_name"); while($rows = mysql_fetch_array($result)){ echo $rows['name'] . " " .$rows['email'] . " " . $rows['phoneno'] . " " . $rows['comments'] . "<br>"; } mysql_close(); //close database ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.