Jump to content

iMiles

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Everything posted by iMiles

  1. Ah, that fixed it. Thanks both for your replies
  2. As the title says, my headers not redirecting. Login.php: <?php include("global.php"); if (isset($_POST['login'])) { // Form data $email = $_POST['email']; $password = $_POST['password']; // If email and password are both filled in if ($email && $password) { mysql_select_db("social_site") or die("Can\'t find database!"); $query = mysql_query("SELECT * FROM users where email = '$email'"); $numrows = mysql_num_rows($query); // If email in database if ($numrows != 0) { // Login while ($row = mysql_fetch_assoc($query)) { $dbemail = $row['email']; $dbpassword = $row['password']; } if ($email == $email && $password == $dbpassword) { // User is logged in header(' location: index.php '); } else { echo "Incorrect password."; } } else { echo "That email does not exist."; } } else { echo "Please fill in <strong>all</strong> fields."; } } ?> <p> <html> <form action = 'login.php' method = 'POST'> Email: <input type = 'text' name = 'email'> <p> Password: <input type = 'text' name = 'password'> <p> <input type = 'submit' name = 'login' value = 'Login'> </form> </html> Global.php: <?php // This is the global file for the entire website // Start a session session_start(); // Start MySQL connection mysql_connect('localhost', 'root', 'root'); ?> Any ideas?
  3. Thanks! Work's just fine now.
  4. Hey there, I'm making a file upload php page. I needs to make sure the file being uploaded has an allowed extension. Allowed extensions are stored in a array called $allow. I'm trying to use strpos(). Upload.php: <?php if (isset($_POST['upload'])) { // Properties of the file $name = $_FILES["filename"]["name"]; $type = $_FILES["filename"]["type"]; $size = $_FILES["filename"]["size"]; $temp = $_FILES["filename"]["tmp_name"]; $allow = array('.java', '.class'); $error = $_FILES["filename"]["error"]; if ($error > 0) { echo "Error uploading file! Code $error."; } else { if (strpos($name, $allow) == false) { // Of course this won't work, but what will? echo "File type not allowed!"; } else { move_uploaded_file($temp, "games/" . $name); echo "Successfully uploaded game."; } } } ?> <p> <html> <p> <form action = 'upload.php' method = 'POST' enctype = 'multipart/form-data'> <input type = 'file' name = 'filename'> <p> <input type = 'submit' name = 'upload' value = 'Upload'> </form> </html> Any help would be appreciated.
  5. Hey there, lookie here: <?php class user { // Initialize the variables var $id; var $firstname; function __construct() { // Now add the session variables $this -> id = $_SESSION['id']; $connect = mysql_connect("localhost", "root", "root"); $query = mysql_query("SELECT * FROM users where id = '$this -> id'"); } } ?> I get this error: Catchable fatal error: Object of class user could not be converted to string in /Users/home/Desktop/Miles/HS/classes.php on line 18 Ideas?
  6. So I removed the "Var", but it still doesn't work. What should I do?
  7. Hey there, so I have a class: <?php session_start(); class user { var $id = $_SESSION['id']; var $username = $_SESSION['username']; var $firstname = $_SESSION['firstname']; var $lastname = $_SESSION['lastname']; } ?> When I run the page, I get this error: Parse error: syntax error, unexpected T_VARIABLE in /Users/home/Desktop/Miles/HS/classes.php on line 7 Any ideas?
  8. Hey all, I'm working on a Content Management System, and need some help. When you install my CMS, it asks for a MySQL Host, Username, and password. Somehow I need to write these variables to a config file to be accessed later. I'm looking for the correct way to go about this
  9. Thanks, I actually ended up using the error_reporting() function and setting it's value to 0. That fixed everything nicely!
  10. So I came across a problem when I was making a form that allows a user to connect to their mySQL database. Here's the code: if ($_POST['submit']) { $sqlhost=$_POST['sqlhost']; $sqluser=$_POST['sqluser']; $sqlpass=$_POST['sqlpass']; $errorstring=""; //error checking if ($sqlhost=="") { $errorstring.="Host cannot be left empty!<br>"; } if ($sqluser=="") { $errorstring.="User cannot be left empty!<br>"; } //if their are errors display the error message if ($errorstring<>"") { echo "<center id=\"error\">$errorstring</center><p>"; } else //no errors mysql_connect("$sqlhost","$sqluser","$sqlpass") or die ("Unable to connect!"); Alright, that looks all good and dandy? It is. The only problem is if the user types in a database that we cannot connect to, it displays an error: Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'rssr' (1) in /Applications/XAMPP/xamppfiles/htdocs/install.php on line 40 Unable to connect! Thing is, I don't want it to display that error. I only want it to display my error, which is "Unable to connect", and not the computer generated error. Hope you understand what the hell I'm talking about :-\ - Miles
×
×
  • 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.