Jump to content

Aaron4osu

Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by Aaron4osu

  1. I have a form that sends a confirmation email to the user who filled out the form. It worked for a while then suddenly stopped working for my email address which I had been using to test the form. It still forms for some email address, just not one with a specific domain. Could their be any kind of spam filter issues for how I have it configured? $mail->SetFrom('emailAddress', 'Name');$mail->AddReplyTo('emailAddress', 'Name'); $mail->AddAddress('emailAddress', 'Name');$mail->Subject = $subject;$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($requester_message);if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo;} else { //echo "Message sent!";} // end else
  2. I'm working on a site that allows users to vote on different items. Right now I have it so after they vote the buttons are disabled until the page refreshes. I want to come up with a solution so I can keep users from voting more than once. Currently, I'm storing votes in a mysql database, but I'm not storing who voted. I have 3 different types of users. 1) members logged in 2)members not logged in 3)site visitors with no user account I'm trying to think of the best ways to handle each type. I know for my logged in users I can use their user_id and check if they have voted before for that specific element. But how should I handle the other two (2 & 3). Here is what I'm thinking... a) Should I use set a cookie for each of their votes. Then, loop through all of their vote cookies each time they vote before adding the vote to the database? There could be hundreds of votes. If they have cookie turned off this would not work. b)maybe grab their ipaddress somehow and store that in the database. Then query and loop through all votes looking for a duplicate ipaddress/item combo? c)something more efficient?
  3. I'm trying to build a query that joins 3 tables but I can't seem to figure it out. I want pull all records from the cast table where cast.cast_video_id=1. It should return several users and I want to list their info which is listed in the users table and their position name which is in the position table. here is what I have thus far which returns this error: ERROR: Please separate SQL statements with the Statement Delimiter Preference value - currently ; - when using Execute All SELECT users.first_name, users.last_name, users.city, users.state, cast.cast_pos_id, cast.cast_video_id, positions.pos_name, cast.cast_user_id, users.user_pic_path FROM users INNER JOIN (positions INNER JOIN [cast] ON positions.pos_id = cast.cast_pos_id) ON users.user_id = cast.cast_user_id where cast.cast_video_id=1; here are my mysql tables used in query CREATE TABLE `cast` ( `cast_id` int(11) NOT NULL AUTO_INCREMENT, `cast_user_id` int(11) DEFAULT NULL, `cast_video_id` int(11) DEFAULT NULL, `cast_pos_id` int(11) DEFAULT NULL, `cast_detail` varchar(200) DEFAULT NULL, PRIMARY KEY (`cast_id`), FOREIGN KEY(cast_user_id) REFERENCES users(user_id), FOREIGN KEY(cast_video_id) REFERENCES videos(vid_id), FOREIGN KEY(cast_pos_id) REFERENCES positions(pos_id) ); CREATE TABLE `users` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `user_name` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `password` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `first_name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `last_name` varchar(30) COLLATE utf8_unicode_ci NOT NULL, `city` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `state` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `zip` int(5) DEFAULT NULL, `email` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `user_pic_path` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`user_id`), FOREIGN KEY(user_pos_id) REFERENCES positions(pos_id) ); CREATE TABLE `positions` ( `pos_id` int(11) NOT NULL AUTO_INCREMENT, `pos_name` varchar(30) COLLATE utf8_unicode_ci NOT NULL, `pos_desc` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`pos_id`) );
  4. Actually I think the initial post fixed it, but for some reason my ftp client wasn't copying over the previous version so I kept running the same script. Very sorry and thanks for the help. This is what I ended up using which is working perfect. <?php session_start(); session_unset(); session_destroy(); header("Location: http://aaronhaas.com/pitchshark6/index.php?vid_id=1"); ?>
  5. Also, I just noticed something else that is weird. I accidentally took out the header function that redirects back to the index page but it is still redirecting there without it. I've tried clear the cache and removing the file and replacing it again and still doing the same. Is that normal for a php script to return back to the previous page?
  6. Thanks guys but I'm still trouble. Ive tried both of these and neither is working for me: I also tried taking out everything but the unset lines. <?php session_start(); session_unset(); session_destroy(); ?> and <?php session_start(); unset($_SESSION); session_destroy(); ?>
  7. I'm trying to use this php to clear out the session variables and return to the index page. However it's not clearing them out. Any ideas? logout.php <?php session_start(); unset($_SESSION['user_id']); unset($_SESSION['username']); session_destroy(); header("Location: http://aaronhaas.com/pitchshark6/index.php?vid_id=1"); ?> then in my navigation I'm using this code to either display their username and a logout link to logout.php or if they are not logged in display a sign in link. <?php // if logged in if (isset($_SESSION['user_id'])) { // display echo "<a href='#'>".$_SESSION['username']."</a> "; echo "<a href='scripts/logout.php'>Log Out</a> "; } // if not logged in else { // display login link echo "<a href='login.php'>Sign In</a>"; } ?> here is my super simple login script $username = $_POST['username']; $password = $_POST['password']; //Check if the username or password boxes were not filled in if(!$username || !$password){ //if not display an error message echo "<center>You need to fill in a <b>Username</b> and a <b>Password</b>!</center>"; }else{ // find user by username and password - working $userQuery = 'SELECT * FROM users WHERE user_name ='.'"'. $username.'" AND password='.'"'. $password.'"' ; $users = mysql_query($userQuery); $user = mysql_fetch_array($users); $_SESSION['user_id'] = $user['user_id']; $_SESSION['username'] = $user['username']; header("Location: http://aaronhaas.com/pitchshark6/index.php?vid_id=1"); }
  8. sorry just saw the post on headers
  9. I was hoping I could get someone to look at my ERD and let me know if it looks ok. Below is an explanation and I attached a pdf of my erd. I'm creating a website where a user can: 1)create a profile 2)then have the ability to create many projects. each project along with the other fields will have drop down menus for: -Genre -Format -Status 3) The project creator will assign positions needed for the project. The project crew table will have a drop down menu (crew positions) with types of crew positions (producer, director, etc...). Until a position is filled it will have an open to apply status. When the position is filled the users name will appear for that position. 4) Each Project Crew Position(in the project crew table) will have many users apply to that position. They will be stored in the audition table. Anyway, I hope this makes sense. If you have any questions I'll be monitoring this closely and get respond quickly. Thanks 17588_.pdf
  10. I'm trying to create a database driven poll to allow users to "like" or "dislike" each video on my site. But instead of radio buttons and a submit button I want to use images with jquery handling the submit when a choice is made. I have found 2 tutorials that each accomplish part of what I want. This tutorial has a poll which is perfect because I can pass in a poll id (which will be the same value as my video id) and it will load that video's poll. http://www.webresourcesdepot.com/ajax-poll-script-with-php-mysql-jquery/ This tutorial replaces the radio buttons with images. http://www.weblee.co.uk/2009/05/30/radio-button-replacement-with-style/ I have them both working separately on this page http://aaronhaas.com/poll2/ I can't seem to figure out how to combine the two together. The poll script generates its html inside of a php function. In the code below I have commented out the line ( getPoll(1) ) that calls the function and replaced it with the html it generates to make it easier to see what is going on. Another problem is each form has a different action so both actions somehow need to be combined together into a function. I was hoping someone might want to see if they can combine the two together and post it as a tutorial or demo. <?php require("inc/db.php"); require("inc/functions.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>Ajax Poll Script - Demo</title> <!-- styles and js for poll --> <script src="inc/js/jquery-1.4.2.min.js" type="text/javascript"></script> <script src="inc/js/poll.js" type="text/javascript"></script> <style> body { font-family: Arial, Helvetica, sans-serif; font-size: 1em; } #pollWrap{ width: 550px; margin-left:40px; } #pollWrap h3 { display:none; color:red; font-size: 1em; margin-bottom: 5px; display:none; } #pollWrap ul { margin: 0; padding: 0 0 0 5px; } #pollWrap li { padding: 0; /*overflow:hidden;*/ /*for our lovely friend IE6 to behave nicely*/ font-size: 0.8em; display: inline; } #pollWrap li span { font-size: 0.7em; } .pollChart { margin-left: 25px; height: 10px; width:1px; /*Adding rounded corners to the graphs - Optional - START*/ -moz-border-radius-topright: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-top-right-radius: 4px; -webkit-border-bottom-right-radius: 4px; /*Adding rounded corners to the graphs - Optional - END*/ } #pollSubmit { margin-top: 5px; } #pollMessage { color:#C00; font-size: 0.8em; font-weight: bold; } </style> <!-- styles and js for image radio buttons --> <link rel="stylesheet" type="text/css" href="css/radio.css"> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="js/radio-demo.js"></script> </head> <body> <div id="greenlight"> <div id="options"> <ul id="list"> <li class="active"><a href="#" class="option1 active" id="link1"><span>Option</span></a></li> <li><a href="#" class="option2" id="link2"><span>Option</span></a></li> </ul> </div> <!-- close options --> <form action="step2.html" method="post" id="radioform"> Green Light: <input name="option1" type="radio" value="option1" id="option1" checked="checked" /><br /> Cancel: <input name="option1" type="radio" value="option2" id="option2" /><br /> </form> <!-- <p><a href="#" class="toggleform">Show Hidden Form Radion Buttons</a></p> --> <?php // getPoll(1); //$pollID ?> <div id="pollWrap"> <form name="pollForm" method="post" action="inc/functions.php?action=vote"> <h3>Poll Question 1</h3> <ul> <li> <input name="pollAnswerID" id="pollRadioButton1" value="1" type="radio"> Answer1 for Poll1 <span id="pollAnswer1"></span> </li> <li class="pollChart pollChart1"></li> <li> <input name="pollAnswerID" id="pollRadioButton2" value="2" type="radio"> Answer2 for Poll1 <span id="pollAnswer2"></span> </li> <li class="pollChart pollChart2"></li> </ul> <input name="pollSubmit" id="pollSubmit" value="Vote" type="submit"> <span id="pollMessage"></span> <img src="ajaxLoader.gif" alt="Ajax Loader" id="pollAjaxLoader"> </form> </div> </div><!-- close greenlight --> </body> </html>
  11. I'm getting the following error after running a query when I run mysql_fetch_array(): Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in public_html/pitchShark2/Poll/inc/functions.php on line 24 Any help will be greatly Line 24 is: while($row = mysql_fetch_array($result)) // app_config.php defines: DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD <?php require_once '../scripts/app_config.php'; require_once '../scripts/database_connection.php'; //require("db.php"); //GETTING VARIABLES START if (isset($_POST['action'])) { $action = mysql_real_escape_string($_POST['action']); } if (isset($_POST['pollAnswerID'])) { $pollAnswerID = mysql_real_escape_string($_POST['pollAnswerID']); } //GETTING VARIABLES END function getPoll($pollID){ $query = "SELECT * FROM polls LEFT JOIN pollAnswers ON polls.pollID = pollAnswers.pollID WHERE polls.pollID = " . $pollID . " ORDER By pollAnswerListing ASC"; $result = mysql_query($query); //echo $query;jquery $pollStartHtml = ''; $pollAnswersHtml = ''; while($row = mysql_fetch_array($result)) { $pollQuestion = $row['pollQuestion']; $pollAnswerID = $row['pollAnswerID']; $pollAnswerValue = $row['pollAnswerValue']; if ($pollStartHtml == '') { $pollStartHtml = '<div id="pollWrap"><form name="pollForm" method="post" action="inc/functions.php?action=vote"><h3>' . $pollQuestion .'</h3><ul>'; $pollEndHtml = '</ul><input type="submit" name="pollSubmit" id="pollSubmit" value="Vote" /> <span id="pollMessage"></span><img src="ajaxLoader.gif" alt="Ajax Loader" id="pollAjaxLoader" /></form></div>'; } $pollAnswersHtml = $pollAnswersHtml . '<li><input name="pollAnswerID" id="pollRadioButton' . $pollAnswerID . '" type="radio" value="' . $pollAnswerID . '" /> ' . $pollAnswerValue .'<span id="pollAnswer' . $pollAnswerID . '"></span></li>'; $pollAnswersHtml = $pollAnswersHtml . '<li class="pollChart pollChart' . $pollAnswerID . '"></li>'; } echo $pollStartHtml . $pollAnswersHtml . $pollEndHtml; } function getPollID($pollAnswerID){ $query = "SELECT pollID FROM pollAnswers WHERE pollAnswerID = ".$pollAnswerID." LIMIT 1"; $result = mysql_query($query); $row = mysql_fetch_array($result); return $row['pollID']; } function getPollResults($pollID){ $colorArray = array(1 => "#ffcc00", "#00ff00", "#cc0000", "#0066cc", "#ff0099", "#ffcc00", "#00ff00", "#cc0000", "#0066cc", "#ff0099"); $colorCounter = 1; $query = "SELECT pollAnswerID, pollAnswerPoints FROM pollAnswers WHERE pollID = ".$pollID.""; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { if ($pollResults == "") { $pollResults = $row['pollAnswerID'] . "|" . $row['pollAnswerPoints'] . "|" . $colorArray[$colorCounter]; } else { $pollResults = $pollResults . "-" . $row['pollAnswerID'] . "|" . $row['pollAnswerPoints'] . "|" . $colorArray[$colorCounter]; } $colorCounter = $colorCounter + 1; } $query = "SELECT SUM(pollAnswerPoints) FROM pollAnswers WHERE pollID = ".$pollID.""; $result = mysql_query($query); $row = mysql_fetch_array( $result ); $pollResults = $pollResults . "-" . $row['SUM(pollAnswerPoints)']; echo $pollResults; } //VOTE START if ($action == "vote"){ if (isset($_COOKIE["poll" . getPollID($pollAnswerID)])) { echo "voted"; } else { $query = "UPDATE pollAnswers SET pollAnswerPoints = pollAnswerPoints + 1 WHERE pollAnswerID = ".$pollAnswerID.""; mysql_query($query) or die('Error, insert query failed'); setcookie("poll" . getPollID($pollAnswerID), 1, time()+259200, "/", ".webresourcesdepot.com"); getPollResults(1); } } //VOTE END if (mysql_real_escape_string($_GET['cleanCookie']) == 1){ setcookie("poll1", "", time()-3600, "/", ".webresourcesdepot.com"); header('Location: http://webresourcesdepot.com/wp-content/uploads/file/ajax-poll-script/'); } ?> database_connection.php <?php require_once 'app_config.php'; mysql_connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD) or handle_error("there was a problem connecting to the database that holds the information we need to get you connected.", mysql_error()); mysql_select_db(DATABASE_NAME) or handle_error("there's a configuration problem with our database.", mysql_error());
  12. I'm trying to manually insert a url into a video table. But it is a long url with all kinds of special characters Here is an example: <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="640" height="320" id="viddler_gridweb_2"><param name="movie" value="//www.viddler.com/player/35da7dee/"/><param name="allowScriptAccess" value="always"/><param name="allowNetworking" value="all"/><param name="allowFullScreen"value="true"/><param name="flashVars" value="f=1&autoplay=f&loop=0&nologo=0&hd=0"/><embed src="//www.viddler.com/player/35da7dee/" width="640" height="320" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" allowNetworking="all" name="viddler_gridweb_2" flashVars="f=1&autoplay=f&loop=0&nologo=0&hd=0"></embed></object> Is there a way without trying to escape all of the characters?
  13. I'm working on a script that take information from a form and enters it into a mysql database. Everything was working except that the way it is written you must select an image to upload to your profile. I wanted to make the image upload part optional so I added an if/else to the script. If (user supplies image) { process image } else { use missing image icon } I'm getting the following error :Parse error: syntax error, unexpected T_ELSE ... on line 70 (which is where I have my else statement. From reading the forums it sounds like I'm missing a curly brace, but there I think I have the braces right. Here is the part of the code described. Line 70 is :else { <?php // if user provided image if (!empty($_FILES[$image_fieldname])) { // Make sure we didn't have an error uploading the image ($_FILES[$image_fieldname]['error'] == 0) or handle_error("the server couldn't upload the image you selected.", $php_errors[$_FILES[$image_fieldname]['error']]); // Is this file the result of a valid upload? // The @ supresses PHP's errorfor this and uses our custom version instead. @is_uploaded_file($_FILES[$image_fieldname]['tmp_name']) or handle_error("you were trying to do something naughty. Shame on you!", "Uploaded request: file named '{$_FILES[$image_fieldname]['tmp_name']}'"); // Is this actually an image? @getimagesize($_FILES[$image_fieldname]['tmp_name']) or handle_error("you selected a file for your picture that isn't an image.", "{$_FILES[$image_fieldname]['tmp_name']} isn't a valid image file."); // Name the file uniquely $now = time(); while (file_exists($upload_filename = $upload_dir . $now . '-' . $_FILES[$image_fieldname]['name'])) { $now++; // Finally, move the file to its permanent location @move_uploaded_file($_FILES[$image_fieldname]['tmp_name'], $upload_filename) or handle_error("we had a problem saving your image to its permanent location.", "permissions or related error moving file to {$upload_filename}"); } // end if user provided image else { // set file name equal to missing picture icon $upload_filename = "uploads/profile_pics/missing_user.png"; } ?> I also inclused the entire file if you need to see that. <?php require_once 'scripts/app_config.php'; require_once 'scripts/database_connection.php'; $upload_dir = SITE_ROOT . "uploads/profile_pics/"; $image_fieldname = "user_pic"; // Potential PHP upload errors $php_errors = array(1 => 'Maximum file size in php.ini exceeded', 2 => 'Maximum file size in HTML form exceeded', 3 => 'Only part of the file was uploaded', 4 => 'No file was selected to upload.'); $first_name = trim($_REQUEST['first_name']); $last_name = trim($_REQUEST['last_name']); $username = trim($_REQUEST['username']); $password = trim($_REQUEST['password']); $email = trim($_REQUEST['email']); $bio = trim($_REQUEST['bio']); $facebook_url = str_replace("facebook.org", "facebook.com", trim($_REQUEST['facebook_url'])); $position = strpos($facebook_url, "facebook.com"); if ($position === false) { $facebook_url = "http://www.facebook.com/" . $facebook_url; } $twitter_handle = trim($_REQUEST['twitter_handle']); $twitter_url = "http://www.twitter.com/"; $position = strpos($twitter_handle, "@"); if ($position === false) { $twitter_url = $twitter_url . $twitter_handle; } else { $twitter_url = $twitter_url . substr($twitter_handle, $position + 1); } // if user provided image if (!empty($_FILES[$image_fieldname])) { // Make sure we didn't have an error uploading the image ($_FILES[$image_fieldname]['error'] == 0) or handle_error("the server couldn't upload the image you selected.", $php_errors[$_FILES[$image_fieldname]['error']]); // Is this file the result of a valid upload? // The @ supresses PHP's errorfor this and uses our custom version instead. @is_uploaded_file($_FILES[$image_fieldname]['tmp_name']) or handle_error("you were trying to do something naughty. Shame on you!", "Uploaded request: file named '{$_FILES[$image_fieldname]['tmp_name']}'"); // Is this actually an image? @getimagesize($_FILES[$image_fieldname]['tmp_name']) or handle_error("you selected a file for your picture that isn't an image.", "{$_FILES[$image_fieldname]['tmp_name']} isn't a valid image file."); // Name the file uniquely $now = time(); while (file_exists($upload_filename = $upload_dir . $now . '-' . $_FILES[$image_fieldname]['name'])) { $now++; // Finally, move the file to its permanent location @move_uploaded_file($_FILES[$image_fieldname]['tmp_name'], $upload_filename) or handle_error("we had a problem saving your image to its permanent location.", "permissions or related error moving file to {$upload_filename}"); } // end if user provided image else { // set file name equal to missing picture icon $upload_filename = "uploads/profile_pics/missing_user.png"; } $insert_sql = sprintf("INSERT INTO users " . "(first_name, last_name, username, " . "password, email, " . "bio, facebook_url, twitter_handle, " . "user_pic_path) " . "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');", mysql_real_escape_string($first_name), mysql_real_escape_string($last_name), mysql_real_escape_string($username), mysql_real_escape_string(crypt($password, $username)), mysql_real_escape_string($email), mysql_real_escape_string($bio), mysql_real_escape_string($facebook_url), mysql_real_escape_string($twitter_handle), mysql_real_escape_string($upload_filename)); // Insert the user into the database mysql_query($insert_sql) or handle_error(mysql_error()); // Redirect the user to the page that displays user information header("Location: show_user.php?user_id=" . mysql_insert_id()); ?>
  14. I'm trying to check the number of results returned in a query. Currently there is one result being returned but i'm getting this error when I try to run line 38: $num_rows = mysql_num_rows($ratings); Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/haas12/public_html/login/rateVideo.php on line 38 Rows $ratingsQuery = "SELECT * FROM haas12_test.ratings "; $ratings = mysqli_query($conn, $ratingsQuery) or die ("Couldn't execute query."); $num_rows = mysql_num_rows($ratings); echo "$num_rows Rows\n";
  15. Thanks! That fixed that part, but I tried to do the same think here and it isn't working. $query = "SELECT * FROM haas12_test.videos where username = \"$username\""; It works if I substitute $username for an actual username from the database. I read the link you posted on the heredoc method but it didn't understand it.
  16. I'm trying to input the results from a query into html, but I'm just getting the variable names rather than their values. I used single quotes for the echo statement, but I think I must need to switch to double to do that. But then I have problems with the double quotes from the class names (ex. class="SideBoxTitle"). <?php // get user's videos from database $conn = mysqli_connect($dbhost, $dbuser, $dbpass) or die("MySQL Error: " . mysql_error()); $query = "SELECT * FROM haas12_test.videos"; $result = mysqli_query($conn, $query) or die ("Couldn't execute query."); while($row = mysqli_fetch_assoc($result)) { extract($row); echo ' <div id="topBox" class="mainVideoSideBoxes" > <div class="SideBoxTitle" ><h3> $vidtitle </h3> </div><!-- close SideBoxTitle --> <div class="sideBoxVidContainer"> <div class="SideBoxScreenCast" > $vidurl </div><!-- close SideBoxScreenCast --> <div class="SideBoxDesc" ><p> $viddesc </p> </div><!-- close SideBoxDesc --> </div><!-- close sideBoxVidContainer --> </div><!-- close mainVideoSideBoxes --> </div><!-- close mainVideoSideBoxes --> '; // end echo staement } ?>
  17. I always forget to look at the line above the error. Thanks!!!
  18. I'm getting the following error when the $query = mysql_query line runs: Parse error: syntax error, unexpected T_VARIABLE $vidtitle = strip_tags(trim($_POST['vidtitle'])); $viddesc = strip_tags(trim($_POST['viddesc'])); $vidtags = strip_tags(trim($_POST['vidtags'])); $vidurl = strip_tags(trim($_POST['vidurl'])); // get current username $username = $_SESSION['Username'] // register user $query = mysql_query("INSERT INTO haas12_test.videos (vidtitle, viddesc, vidtags, vidurl, username) VALUES('".$vidtitle."', '".$viddesc."', '".$vidtags."', '".$vidurl."', '".$username."')"); it worked fine before I added the username variables.
  19. Just want to introduce myself. I just graduated with a Web Development Degree but still don't have too much practical experience programming in PHP other than processing forms. I have a big project I'll be working on for the next 12 to 25 weeks so I'm sure I'll be in here quite a bit. I have had a great experience in here so far. Questions seem to get answered very quickly and accurately. I look forward to the day where I can contribute to the other side of the help equation. A little bit about me: I live and die The Ohio State Buckeyes, I brew my own beer and also make my own wine and hard cider. Thanks in advance for all of your help, Aaron
  20. I'm having trouble getting my script to refresh the page. If the username, password match it falls into this if statement. Sometimes it works and other times and won't refresh the page automatically. I'm trying to use this line to refresh the page echo "<meta http-equiv='refresh' content='=2;index.php' />"; Here is the if statement if(mysql_num_rows($checklogin) == 1) { // store the row returned from query $row = mysql_fetch_array($checklogin); // get email address from row returned $email = $row['EmailAddress']; // store user variables in session array $_SESSION['Username'] = $username; $_SESSION['EmailAddress'] = $email; $_SESSION['LoggedIn'] = 1; // boolean echo "<h1>Success</h1>"; echo "<p>We are now redirecting you to the member area.</p>"; echo "<meta http-equiv='refresh' content='=2;index.php' />"; } here is the entire index.php file <?php include "base.php";?> <!-- base.php contains session_start() --> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>User Management System (Tom Cameron for NetTuts)</title> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div id="main"> <?php // check if user is already logged in if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])) { ?> <h1>Pitch Shark Member Area</h1> <p>Thanks for logging in! You are <b><?=$_SESSION['Username']?><b> and your email address is <b><?=$_SESSION['EmailAddress']?></b>.</p> <ul> <!-- link that runs logout.php script --> <li><a href="logout.php">Logout.</a></li> </ul> <?php } // check login form elseif(!empty($_POST['username']) && !empty($_POST['password'])) { // strip away malicious code $username = mysql_real_escape_string($_POST['username']); // encrypt password $password = md5(mysql_real_escape_string($_POST['password'])); // return all matches to username and password $checklogin = mysql_query("SELECT * FROM haas12_test.users WHERE Username = '".$username."' AND Password = '".$password."'"); // if there is a match if(mysql_num_rows($checklogin) == 1) { // store the row returned from query $row = mysql_fetch_array($checklogin); // get email address from row returned $email = $row['EmailAddress']; // store user variables in session array $_SESSION['Username'] = $username; $_SESSION['EmailAddress'] = $email; $_SESSION['LoggedIn'] = 1; // boolean echo "<h1>Success</h1>"; echo "<p>We are now redirecting you to the member area.</p>"; echo "<meta http-equiv='refresh' content='=2;index.php' />"; } // if there information entered could not be found else { echo "<h1>Error</h1>"; echo "<p>Sorry, your account could not be found. Please <a href=\"index.php\">click here to try again</a>.</p>"; } } // display login form with link to register form else { ?> <h1>Member Login</h1> <p>Thanks for visiting! Please either login below, or <a href="register.php">click here to register</a>.</p> <form method="post" action="index.php" name="loginform" id="loginform"> <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 /> <input type="submit" name="login" id="login" value="Login" /> </fieldset> </form> <?php } ?> </div> </body> </html>
  21. That did it Thanks for the super quick response!!!
  22. I'm getting an Error code: 1064 when I try to create the following table: It says it is at or near line 6 which is the email field. Any ideas? Also do I need the last line? ENGINE=MyISAM DEFAULT CHARSET=utf8;) This was taken from a tutorial that is a couple of years old. I'm using using MySQL Version: 5.1.56 CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL auto_increment, `username` varchar(32) NOT NULL, `password` varchar(32) NOT NULL, `online` int(20) NOT NULL default ‘0', `email` varchar(100) NOT NULL, `active` int(1) NOT NULL default ‘0', `rtime` int(20) NOT NULL default ‘0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
×
×
  • 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.