Jump to content

mr_nabo

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mr_nabo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, Hope you can help me with my code. I can't seem to figure out how to set up a MySQL-based password and username php app. Here's my code, it just goes blank when I run it and I can't figure out why. Anyone help? Thanks <?php require_once('header.inc'); ?> <?php require_once('dbconnect.php'); // Select the Database if (!@mysql_select_db('wedding')) { exit('<p>Can\'t select the WEDDING database</p>'); } session_start(); $_SESSION['logged'] = 0; if (isset($_POST['submit'])) { $sql = "SELECT * FROM people WHERE username='$_POST['username']'"; //make sure tablename and username match your form and database $sql = mysql_query($sql); $result = mysql_fetch_assoc($sql); if($_POST['username'] == $result['username'] && $_POST['password'] == $result['password']) { $_SESSION['user'] = $result['id']; $_SESSION['logged'] = 1; exit('Login success'); } else { exit('Login Failed. Please try putting in your details again'); } ?>
  2. Hi, I've looked pretty hard to find more information about IF statements and how I could strip underscores/extensions etc. but I'm having trouble getting anywhere. I'm pretty new to PHP but eager to learn. Here's the code I have below, I'd like to strip underscores and extensions like .mpg from the filename, capitalize the first letter of each word and remove the first three characters of the filename. I'm pretty sure the functions I need are str_replace(), trim() and ucwords() but I can't work out how to get them into the code properly. Can anyone help me out? Here's the code. Cheers [code]<!-- display folder contents --> <?php   function directory($result)   {        $handle=@opendir("demos");   // while ( conditional statement is true){.....do this code ;}   while ($file = readdir($handle))   {   // The || means 'or' and '=='' means 'is equal to' so this statement   // means that IF the file has one (.) OR two (..) characters to do nothing   if ($file == "." || $file == "..")   {   }   // Otherwise...   else   {     // print out directory link and filesize.   print "<p class=\"demos\">   <a href=\"demos/$file\">$file</a><br />   (<font class=\"filesize\"><i>size: " . round(filesize("demos/$file")/1024/1024, 2) . " mb / " . round(filesize("demos/$file")/1024, 2) . " kb)</i></font></p>";   }   }   closedir($handle);       return $result;    }   echo directory($result); ?>[/code]
×
×
  • 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.