Jump to content

Akenatehm

Members
  • Posts

    262
  • Joined

  • Last visited

    Never

Everything posted by Akenatehm

  1. Okay, a session ID is being echoed. So the session must be starting succesfully?
  2. Hey Guys, Im having a really frustrating problem with this set of PHP: writeConversationFunctions.php <?php session_start(); the function writeMessage($message){ $_SESSION['messagetest'] = $message; $chatLogFile = "log.txt"; $openChatLog = fopen($chatLogFile, 'w') or die("Failed to open Log File."); if($message == "resetnow"){ $message = ""; fwrite($openChatLog, $message); fclose($openChatLog); $_SESSION['lastMessageSize'] = 0; } elseif($message == ""){ } else{ $timestamp = date("h:i"); if(isset($_SESSION['username'])){ $username = $_SESSION['username']; } else{ $username = "Anonymous"; } if($message[0] == "/"){ $commandString = stripslashes($commandString); $commandString = htmlentities($commandString, ENT_QUOTES, 'UTF-8'); $commandString = substr($commandString, 1); $command = explode(" ",$commandString); switch ($command[0]){ case "slap": $name = command[1]; $commandResponse = '<p class="commandText">' ."You slap " . $name . "across the face.</p>"; fwrite($openChatLog, $commandResponse); fclose($openChatLog); break; } } else{ $message = stripslashes($message); $message = htmlentities($message, ENT_QUOTES, 'UTF-8'); $message = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1" target="_blank">$1</a>', $message); $messageString = ' <p class="message"> <span class="timestamp">' .$timestamp . '</span> <span class="username">' . $username . ': </span>' . $message . '</p>'; fwrite($openChatLog, $messageString); fclose($openChatLog); } } } writeMessage($_POST['message']); ?> Simply, the session at the top will not be created for some reason. The post data is sent from: index.php <?php session_start(); ?> <!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" /> <link rel="stylesheet" type="text/css" href="styles.css" /> <title>Chatulo.us</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script> <script> var n = 0; $(document).ready(function () { var focused = true; $(window).focus(function () { focused = true; f(); }); $(window).blur(function () { focused = false; f(); }); var title = document.title; var f = function () { if (focused) { n = 0; document.title = "Chatulo.us / Home"; } else { // none of that else if needed here, you're only checking is focused or not. if (n == 0) { // now you're checking if its zero, so ... document.title = "Chatulo.us / Home"; } else { // you need ELSE here, otherweise you'll always use this next clause document.title = "(" + n + ") " + "Chatulo.us / Home"; } } }; function playSound(soundfile) { document.getElementById("dummy").innerHTML = "<embed src=\"" + soundfile + "\" hidden=\"true\" autostart=\"true\" loop=\"false\" />"; } $.ajax({ type: "POST", url: "loginHandlers.php", data: { required_function: "checkSession" }, success: function (response) { $('#usernameBox').html(response); } }); $("form#sendMessageForm").submit(function () { var message = $('#messageInputField').attr('value'); $('#messageInputField').val(''); $.ajax({ type: "POST", url: "writeConversationFunctions.php", data: { message: message }, success: function () { update(); } }); return false; }); function update() { $.ajax({ type: "POST", dataType: "json", url: "readConversationFunctions.php", data: { required_function: "readConvo" }, success: function (message) { if (message.newmessage == true) { $('#messageBox').html(message.message); playSound('sounds/pop.mp3'); n = n + 1; f(); } else if (message.newmessage === false) { $('#messageBox').html(message.message); } }, complete: function () { setTimeout(update, 1000) $("#messageBox").attr({ scrollTop: $("#messageBox").attr("scrollHeight") }); } }); } $("form#getUsernameForm").live('submit', function () { var username = $('#usernameInputField').attr('value'); $.ajax({ type: "POST", url: "loginHandlers.php", data: { username: username, required_function: "usernameHandler" }, success: function (response) { $('#usernameBox').html("Processing..."); setTimeout(function () { $('#usernameBox').html(response) }, 1000); } }); return false; }); $("span#logoutText").live('click', function () { $.ajax({ type: "POST", url: "loginHandlers.php", data: { required_function: "removeSession" }, success: function (response) { $('#usernameBox').html("Processing..."); setTimeout(function () { $('#usernameBox').html(response) }, 1000); } }); return false; }); update(); }); </script> </head> <body> <form method="post" name="messageInput" id="sendMessageForm"> <input name="message" id="messageInputField" type="text" autocomplete="off"/> <input name="submit" type="submit" value="Send"/> </form> <div id="messageBox"> </div> <div id="usernameBox"> </div> <span id="dummy"></span> <img src="images/logo.png" width="175" height="50" alt="Logo" id="chatulouslogo"/> </body> </html> Any help with this issue would be GREATLY appreciated! Regards, Cody
  3. Hey Guys, Thanks to your help, I managed to fix some things and it all works fine. Thanks a lot. Much appreciated! Cody
  4. Hey Guys, For some reason, I don't know why this is displaying errors. Help would be appreciated if possible. Member.class.php <?php class Register{ private $dbhost,$dbuser,$dbpass,$database,$LastResult; public function __construct($dbhost,$dbuser,$dbpass,$database) { $this->dbhost = $dbhost; $this->dbuser = $dbuser; $this->dbpass = $dbpass; $this->database = $database; } public function checkUsername($username){ $this->username = mysql_escape_string($username); $connect = mysql_connect($this->dbhost,$this->dbuser,$this->dbpass) or die(mysql_error()); mysql_select_db($this->database) or die(mysql_error()); $checkuser= mysql_query("SELECT * FROM users WHERE Username = '$this->username'") or die(mysql_error()); if(mysql_num_rows($checkuser) == 1){ $response = "Username Already Exists <br />"; } mysql_close($connect); } public function samePasswords($password,$confirmpassword){ $this->password = md5(mysql_escape_string($password)); $this->confirmpassword = md5(mysql_escape_string($confirmpassword)); if($this->password != $this->confirmpassword){ $response = "Passwords Do Not Match<br />"; } } public function checkEmail($email) { $formatTest = '/^[-\w+]+(\.[-\w+]+)*@[-a-z\d]{2,}(\.[-a-z\d]{2,})*\.[a-z]{2,6}$/i'; $lengthTest = '/^(.{1,64})@(.{4,255})$/'; $check = (preg_match($formatTest, $email) && preg_match($lengthTest, $email)); if($check == 'false'){ $response = "Invalid Email<br />"; } } public function createUser($username,$password,$email){ $connect = mysql_connect($this->dbhost,$this->dbuser,$this->dbpass) or die(mysql_error()); mysql_select_db($this->database) or die(mysql_error()); $insertuser = mysql_query("INSERT into users (username,password,email) values('$username','$password','$email')") or die(mysql_error()); if($insertuser){ $response = "<p>Your account was successfully created. Please <a href=\"index.php\">click here to login</a>.</p>"; } elseif(!$insertuser){ $response = "Problem Creating User. Please Try Again Later.<br />"; } mysql_close($connect); } } ?> register.php: <?php session_start(); require "Connection.class.php"; require 'Member.class.php'; $select = new Connection('localhost','root',''); $select->db ('TimelessVoice'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>User Management System (Tom Cameron for NetTuts)</title> <link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" /> <script src="jquery.js" type="text/javascript"></script> <script src="validate/cmxforms.js" type="text/javascript"></script> <script type="text/javascript" src="validate/jquery.validate.js"></script> <script type="text/javascript"> $().ready(function() { // validate signup form on keyup and submit $("#registerform").validate({ rules: { username: { required: true, minlength: 5 }, password: { required: true, minlength: 5 }, confirmpassword: { required: true, minlength: 5, equalTo: "#password" }, email: { required: true, email: true }, messages: { username: { required: "Please enter a username", minlength: "Your username must consist of at least 5 characters" }, password: { required: "Please provide a password", minlength: "Your password must be at least 5 characters long" }, confirm_password: { required: "Please provide a password", minlength: "Your password must be at least 5 characters long", equalTo: "Please enter the same password as above" }, email: "Please enter a valid email address" } } }); }); // check if confirm password is still valid after password changed $("#password").blur(function() { $("#confirmpassword").valid(); }); </script> </head> <body> <div id="main"> <?php if(!empty($_POST['username']) && !empty($_POST['password'])) { $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $database = 'TimelessVoice'; $servervalidation = new Register($dbhost,$dbuser,$dbpass,$database); if(!$servervalidation->checkEmail($_POST['email'])) { echo "<h1>Error1</h1>"; echo $servervalidation->checkEmail->$response; } elseif(!$servervalidation->checkUsername($_POST['username'])) { echo "<h1>Error2</h1>"; echo $servervalidation->checkUsername->$response; } elseif(!$servervalidation->samePasswords($_POST['password'],$_POST['confirmpassword'])) { echo "<h1>Error3</h1>"; echo $servervalidation->samePasswords->$response; } elseif(!$servervalidation->checkEmail($_POST['email'])){ echo "<h1>Error4</h1>"; echo $servervalidation->checkEmail->$response; } else{ $servervalidation->createUser($servervalidation->username,$servervalidation->password,$servervalidation->email); echo $servervalidation->createUser->$response; } } else{ ?> <h1>Register</h1> <p>Please enter your details below to register.</p> <form method="post" action="register.php" name="registerform" id="registerform" class="cmxform"> <fieldset> <label for="username">Username:</label><input type="text" name="username" id="username" /><br /> <label for="password">Password:</label><input type="password" name="password" id="password" /><br /> <label for="confirmpassword">Confirm Password:</label><input type="password" name="confirmpassword" id="confirmpassword" /><br /> <label for="email">Email Address:</label><input type="text" name="email" id="email" /><br /> <input type="submit" name="register" id="register" value="Register" /> </fieldset> </form> <?php } ?> </div> </body> </html> It is outputting "Error1" with no other message. Thanks in Advanced, Cody
  5. Omg, so obvious. Sorry about this guys. Must have accidentally deleted it.
  6. Hey Guys, A bit of a problem here with a small Membership Class that I am working on. Here's the error: Here's Member.class.php: <?php class Register{ private $dbhost,$dbuser,$dbpass,$database,$LastResult; public function __construct($dbhost,$dbuser,$dbpass,$database) { $this->dbhost = $dbhost; $this->dbuser = $dbuser; $this->dbpass = $dbpass; $this->database = $database; } public function checkUsername($username){ $this->username = mysql_escape_string($username); $connect = mysql_connect($this->dbhost,$this->dbuser,$this->dbpass) or die(mysql_error()); mysql_select_db($this->database) or die(mysql_error()); $checkuser= mysql_query("SELECT * FROM users WHERE Username = '$this->username'") or die(mysql_error()); if(mysql_num_rows($checkuser) == 1){ $response = "Username Already Exists <br />"; } mysql_close($connect); } public function samePasswords($password,$confirmpassword){ $this->password = md5(mysql_escape_string($password)); $this->confirmpassword = md5(mysql_escape_string($confirmpassword)); if($this->password != $this->confirmpassword){ $response = "Passwords Do Not Match<br />"; } } public function checkEmail($email) { $formatTest = '/^[-\w+]+(\.[-\w+]+)*@[-a-z\d]{2,}(\.[-a-z\d]{2,})*\.[a-z]{2,6}$/i'; $lengthTest = '/^(.{1,64})@(.{4,255})$/'; $check = (preg_match($formatTest, $email) && preg_match($lengthTest, $email)); if($check == 'false'){ $response = "Invalid Email<br />"; } } public function createUser($username,$password,$email){ $connect = mysql_connect($this->dbhost,$this->dbuser,$this->dbpass) or die(mysql_error()); mysql_select_db($this->database) or die(mysql_error()); $insertuser = mysql_query("INSERT into users (username,password,email) values('$username','$password','$email')") or die(mysql_error()); if($insertuser){ $response = "<p>Your account was successfully created. Please <a href=\"index.php\">click here to login</a>.</p>"; } elseif(!$insertuser){ $response = "Problem Creating User. Please Try Again Later.<br />"; } mysql_close($connect); } } ?> and here is register.php: <?php session_start(); require "Connection.class.php"; require 'Member.class.php'; $select = new Connection('localhost','root',''); $select->db ('TimelessVoice'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>User Management System (Tom Cameron for NetTuts)</title> <link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" /> <script src="jquery.js" type="text/javascript"></script> <script src="validate/cmxforms.js" type="text/javascript"></script> <script type="text/javascript" src="validate/jquery.validate.js"></script> <script type="text/javascript"> $().ready(function() { // validate signup form on keyup and submit $("#registerform").validate({ rules: { username: { required: true, minlength: 5 }, password: { required: true, minlength: 5 }, confirmpassword: { required: true, minlength: 5, equalTo: "#password" }, email: { required: true, email: true }, messages: { username: { required: "Please enter a username", minlength: "Your username must consist of at least 5 characters" }, password: { required: "Please provide a password", minlength: "Your password must be at least 5 characters long" }, confirm_password: { required: "Please provide a password", minlength: "Your password must be at least 5 characters long", equalTo: "Please enter the same password as above" }, email: "Please enter a valid email address" } } }); }); // check if confirm password is still valid after password changed $("#password").blur(function() { $("#confirmpassword").valid(); }); </script> </head> <body> <div id="main"> <?php if(!empty($_POST['username']) && !empty($_POST['password'])) { $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $database = 'TimelessVoice'; if(!$servervalidation->checkEmail($_POST['email'])) { echo "<h1>Error</h1>"; echo $servervalidation->checkEmail->$response; } elseif(!$servervalidation->checkUsername($_POST['username'])) { echo "<h1>Error</h1>"; echo $servervalidation->checkUsername->$response; } elseif(!$servervalidation->samePasswords($_POST['password'],$_POST['confirmpassword'])) { echo "<h1>Error</h1>"; echo $servervalidation->samePasswords->$response; } elseif(!$servervalidation->checkEmail($_POST['email'])){ echo "<h1>Error</h1>"; echo $servervalidation->checkEmail->$response; } else{ $servervalidation->createUser($servervalidation->username,$servervalidation->password,$servervalidation->email); echo $servervalidation->$response; } } else{ ?> <h1>Register</h1> <p>Please enter your details below to register.</p> <form method="post" action="register.php" name="registerform" id="registerform" class="cmxform"> <fieldset> <label for="username">Username:</label><input type="text" name="username" id="username" /><br /> <label for="password">Password:</label><input type="password" name="password" id="password" /><br /> <label for="confirmpassword">Confirm Password:</label><input type="password" name="confirmpassword" id="confirmpassword" /><br /> <label for="email">Email Address:</label><input type="text" name="email" id="email" /><br /> <input type="submit" name="register" id="register" value="Register" /> </fieldset> </form> <?php } ?> </div> </body> </html> Help would be greatly appreciated as I am new to OOP with PHP.
  7. Sorry, was unsure if it did or not. Thanks for that clarification.
  8. WHat does this return? I would rather an If....Else to show a true or false reply. Could you help me with that please?
  9. That really was no help at all. By email validation I mean, checking if it is a valid email address, with correct symbols in right places. NOT validating your account with a link. Help would be appreciated.
  10. I really need help. Can anyone help me please?
  11. Hey Guys, I am working on a small User Management System. It currently validates usernames and checks that passwords match. It is mostly practice for me with OOP PHP. I am trying to get this to validate email also but the page changes and then goes blank once you click on Submit. Here's the Class: <?php class Register{ private $dbhost,$dbuser,$dbpass,$database,$LastResult; public function __construct($dbhost,$dbuser,$dbpass,$database) { $this->dbhost = $dbhost; $this->dbuser = $dbuser; $this->dbpass = $dbpass; $this->database = $database; } public function checkUsername($username){ $this->username = mysql_escape_string($username); $connect = mysql_connect($this->dbhost,$this->dbuser,$this->dbpass) or die(mysql_error()); mysql_select_db($this->database) or die(mysql_error()); $checkuser= mysql_query("SELECT * FROM users WHERE Username = '$this->username'") or die(mysql_error()); if(mysql_num_rows($checkuser) == 1){ $response = "Username Already Exists <br />"; } echo $response; mysql_close($connect); } public function samePasswords($password,$confirmpassword){ $this->password = md5(mysql_escape_string($password)); $this->confirmpassword = md5(mysql_escape_string($confirmpassword)); if($this->password != $this->confirmpassword){ $response = "Passwords Do Not Match<br />"; } echo $response; } /** Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. */ public function checkEmail($email) { $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { // local part length exceeded $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { // domain part length exceeded $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { // local part starts or ends with '.' $isValid = false; } else if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { // character not valid in domain part $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { // character not valid in local part unless // local part is quoted if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; } } if ($isValid && !(checkdnsrr($domain,"MX") || ↪checkdnsrr($domain,"A"))) { // domain not found in DNS $isValid = false; } } return $isValid; } public function createUser($username,$password,$email){ $connect = mysql_connect($this->dbhost,$this->dbuser,$this->dbpass) or die(mysql_error()); mysql_select_db($this->database) or die(mysql_error()); $insertuser = mysql_query("INSERT into users (username,password,email) values('$username','$password','$email')") or die(mysql_error()); if($insertuser){ echo "<h1>Success</h1>"; echo "<p>Your account was successfully created. Please <a href=\"index.php\">click here to login</a>.</p>"; } elseif(!$insertuser){ echo "<h1>Error</h1>"; echo "<p>Sorry, your registration failed. Please go back and try again.</p>"; } mysql_close($connect); } } ?> and the Registration Page: <?php session_start(); require "Connection.class.php"; require 'Member.class.php'; $select = new Connection('localhost','root',''); $select->db ('TimelessVoice'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>User Management System (Tom Cameron for NetTuts)</title> <link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" /> <script src="jquery.js" type="text/javascript"></script> <script src="validate/cmxforms.js" type="text/javascript"></script> <script type="text/javascript" src="validate/jquery.validate.js"></script> <script type="text/javascript"> $().ready(function() { // validate signup form on keyup and submit $("#registerform").validate({ rules: { username: { required: true, minlength: 5 }, password: { required: true, minlength: 5 }, confirmpassword: { required: true, minlength: 5, equalTo: "#password" }, email: { required: true, email: true }, messages: { username: { required: "Please enter a username", minlength: "Your username must consist of at least 5 characters" }, password: { required: "Please provide a password", minlength: "Your password must be at least 5 characters long" }, confirm_password: { required: "Please provide a password", minlength: "Your password must be at least 5 characters long", equalTo: "Please enter the same password as above" }, email: "Please enter a valid email address" } } }); }); // check if confirm password is still valid after password changed $("#password").blur(function() { $("#confirmpassword").valid(); }); </script> </head> <body> <div id="main"> <?php if(!empty($_POST['username']) && !empty($_POST['password'])) { $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $database = 'TimelessVoice'; $servervalidation = new Register($dbhost,$dbuser,$dbpass,$database); $servervalidation->checkUsername($_POST['username']); $servervalidation->samePasswords($_POST['password'],$_POST['confirmpassword']); if($servervalidation->CheckEmail($_POST['email'])){ $servervalidation->createUser($servervalidation->username,$servervalidation->password,$servervalidation->email); } } else{ ?> <h1>Register</h1> <p>Please enter your details below to register.</p> <form method="post" action="register.php" name="registerform" id="registerform" class="cmxform"> <fieldset> <label for="username">Username:</label><input type="text" name="username" id="username" /><br /> <label for="password">Password:</label><input type="password" name="password" id="password" /><br /> <label for="confirmpassword">Confirm Password:</label><input type="password" name="confirmpassword" id="confirmpassword" /><br /> <label for="email">Email Address:</label><input type="text" name="email" id="email" /><br /> <input type="submit" name="register" id="register" value="Register" /> </fieldset> </form> <?php } ?> </div> </body> </html> Help would be greatly appreciated and suggestions will be warmly accepted. Regards, Cody
  12. Hey Guys, I am getting this error: Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ')' in /home/livetwee/public_html/internal/index.php on line 81 with this: <?php case 'returned': /* If the access tokens are already set skip to the API call */ if ($_SESSION['oauth_access_token'] === NULL && $_SESSION['oauth_access_token_secret'] === NULL) { /* Create TwitterOAuth object with app key/secret and token key/secret from default phase */ $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_request_token'], $_SESSION['oauth_request_token_secret']); /* Request access tokens from twitter */ $tok = $to->getAccessToken(); /* Save the access tokens. Normally these would be saved in a database for future use. */ $_SESSION['oauth_access_token'] = $tok['oauth_token']; $_SESSION['oauth_access_token_secret'] = $tok['oauth_token_secret']; } /* Random copy */ $content = 'your account should now be registered with twitter. Check here:<br />'; $content .= '<a href="https://twitter.com/account/connections">https://twitter.com/account/connections</a>'; /* Create TwitterOAuth with app key/secret and user access key/secret */ $to = new TwitterOAuth($consumer_key, $consumer_secret); $tok = $to->getRequestToken(); $request_link = $to->getAuthorizeURL($token); $tok = $to->getAccessToken(); $to = new TwitterOAuth($consumer_key, $consumer_secret, $user_access_key, $user_access_secret); $content = $to->OAuthRequest('https://twitter.com/account/verify_credentials.xml', array(), 'GET'); LINE 81 - >>$content = $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' -> 'Test OAuth update. #testoauth'), 'POST'); /* Run request on twitter API as user. */ //$content = $to->OAuthRequest('https://twitter.com/account/verify_credentials.xml', array(), 'GET'); //$content = $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => 'Test OAuth update. #testoauth'), 'POST'); //$content = $to->OAuthRequest('https://twitter.com/statuses/replies.xml', array(), 'POST'); break; }/*}}}*/ ?>
  13. Thanks. I read through your help and fixed the page. It works great now.
  14. Hey Guys, I get this error: 404 Not Found The requested URL /imagecloud/<br /><b>Warning</b>: Cannot modify header information - headers already sent by (output started at /Library/WebServer/Documents/imagecloud/register.php:51) in <b>/Library/WebServer/Documents/imagecloud/register.php</b> on line <b>44</b><br /> was not found on this server. With this code: <?php session_start(); include 'functions.php'; include 'logregfunctions.php'; function registerUser() { $username = mysql_escape_string($_POST['username']); $password = mysql_escape_string( $_POST['password']); $confirmpassword = mysql_escape_string($_POST['confirmpassword']); $email = mysql_escape_string($_POST['email']); $date = date('l jS \of F Y'); if (isset($_POST['submit'])) { if ($password != $confirmpassword) { $result = '<font color="red"> Your Passwords Did Not Match. Please use the Back button on your browser to go back and provide matching passwords. </font>'; } else { $password = md5($password); $dbhost = "localhost"; $dbuser = "user"; $dbpass = "pass"; $db = "db"; $connect = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); $selectdb = mysql_select_db($db) or die(mysql_error()); $checkusername = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); if (mysql_num_rows($checkusername) == 1) { $result = '<font color="red"> Sorry, that username already exists. Please use the Back button on your browser to go back and choose a new username.</font>'; } else{ $query = mysql_query("INSERT into users (username, password, email, joindate) values('$username','$password','$email','$date')") or die(mysql_error()); mysql_close($connect); $result = '<font color="green"> Congratulations, you have succesfully registered. Please Login in the sidebar to gain access to upload your photos and your account management</font>'; } } } $_SESSION['result'] = $result; $_SESSION['resulttopic'] = "Site - Registration"; header('Location: result.php'); } ?> <html> <head> <title>Site - Registration</title> <link rel="stylesheet" type="text/css" href="styles.css"> <script type='text/javascript'> function formValidator(){ // Make quick references to our fields var name = document.getElementById('username'); var password = document.getElementById('password'); var confirmpassword = document.getElementById('confirmpassword'); var email = document.getElementById('email'); // Check each input in the order that it appears in the form! if(notEmpty(name,"Please Enter Your Desired Username")){ if(notEmpty(password"Please Enter a Password")){ if(notEmpty(email,"Please Enter Your Email Address")){ if(emailValidator(email, "Please Enter a Valid Email Address")){ return true; } } } } return false; } return true; }else{ alert(helperMsg); return false; } } function notEmpty(elem, helperMsg){ if(elem.value.length == 0){ alert(helperMsg); elem.focus(); // set the focus to this input return false; } return true; } function emailValidator(elem, helperMsg){ var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; if(elem.value.match(emailExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } </script> </head> <body> <?php writeHeader(); ?> <div class="wrapper"> <div class="mainleft"> <div class="navbar"><?php whatPage('register');?></div> <br /> <br /> <br /> <br /> <div class="loginbar"> <li class="topmodule">Login</p> <form name="login" method="post" action="<?php checkUserLogin();?>"> <li class="form" id="userlist"> Username: <input type="text" name="username" id="textinput" size="12"></li> <li class="form" id="passlist">Password: <input type="password" name="password" id="textinput" size="12"></li> <li class="bottommodule"><input type="submit" name="submit" class="submit" value="Login" size="12"></li> </form> </div> </div> <div class="maincenter" id="scangreybg"> <p class="maincbheader" >Image Cloud Registration!</p> <p class="maincbtext"></p> <table class="regform"> <form id="regform" action="<?php registerUser();?>" method="post" onSubmit="return formValidator()"> <tr> <td class="regform" width="250px"> <td class="regform" width="120px"> Username: </td> <td class="regform"> <input type="text" name="username" id="username" class="regusername" size="12"> </td> </td> <td class="regform"> <td class="regform"> </td> </td > </tr> <tr> <td class="regform" width="250px"> <td class="regform" width="120px"> Password: </td> <td class="regform"> <input type="password" name="password" id="password" class="regusername" size="12"> </td> </td> <td class="regform"> <td class="regform"> </td> </td > </tr> <tr> <td class="regform" width="250px"> <td class="regform" width="120px"> Confirm Password: </td> <td class="regform"> <input type="password" name="confirmpassword" id="confirmpassword" class="regusername" size="12" > </td> </td> <td class="regform"> <td class="regform"> </td> </td > </tr> <tr> <td class="regform" width="250px"> <td class="regform" width="120px"> Email: </td> <td class="regform"> <input type="text" name="email" id="email" class="regusername" size="12"> </td> </td> <td class="regform"> <td class="regform"> </td> </td > </tr> <tr> <td class="regform" width="250px"> <td class="regform" width="120px"> </td> <td class="regform"> <input type="submit" name="submit" id="submit" class="register" value="Register!"> </td> </td> </tr> <tr> <td class="regform"> </td> <td class="regform" width="200px"></td> </tr> </form> </table> </div> <div class="belowmaincb" id="scangreybg"> <p class="numbertext"><?php checkHowManyImages();?></p> <br /> <p class="bigtext"> Images Uploaded and Counting</p><br /> <p class="tinytext"> Footer</p> </div> </div> </body> Help would be GREATLY appreciated. This is really annoying me and I have searched everywhere. Thanks, Cody
  15. Why doesn't this work? I have tried shortening my code and now none of the below work. a.nav:link:visited{ padding:10px 200px 50px 20px; } a.nav:link:visited:hover{ text-transform: uppercase; text-decoration: none; font-size: 20; background: url(images/greynavmid.png) no-repeat; width:179px; height:38px; line-height: 1.9; color:#78c72c; list-style: none; text-align: left; border: 0; } a.nav:hover{ padding:10px 200px 200px 40px; } HTML: <li class="navitem" id="Info"><a href="info.php"name="Info" class="nav">Info</a></li>
  16. Lol thats a good one Crayon. Could you tell me what you meant?
  17. I don't quite get what you're trying to say to me??
  18. I've given up on the CSS way, surely i can do it through PHP and JAvascript.
  19. Anyone else? Btw. This is now a PHP/Javascript related issue not CSS anymore.
  20. they are the same and shouldnt for any reason change.
  21. the CSS way did not work. What is the other way I can do it?
×
×
  • 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.