Jump to content

silverglade

Members
  • Posts

    727
  • Joined

  • Last visited

    Never

Everything posted by silverglade

  1. Hi, i want to make an image gallery, this is the first step. uploading files. below is the code I am using , but don't i have to include info about the server? i dont know what to include since it is the server I am working with and not a database, any help greatly appreciated. thanks <?php // Where the file is going to be placed $target_path = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> <!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>Untitled Document</title> </head> <body> </body> </html>
  2. i think the best part for me is that i finally read code like english. but it is the coming up with solved problems that is tough. I am posting another problem on the board next, I have a question about uploading images to a directory, I want to make an image gallery.
  3. hahaha Karl! you are awesome that totally made my night. It works perfectly. LOL. its the little things in php that make me happy, like seeing my data pop into a database all nice n tidy. thanks so much for helping me with that. have a great day/night.. Nice avatar btw. :D
  4. thank you Karl. It updates the info, but where the user data should be in the row fields for that user, things like this are in there, literally string names. like this "$name", "dob", "$city". It is putting the variable names in there instead. any help greatly appreciated. here is the code as I adjusted it. /////UPDATE SECTION///// IF (isset($_POST['submit'])){ mysql_query ( "UPDATE users SET firstname='".$first."', lastname='".$last."', dob = '".$dob."', gender='".$gender."', country='".$country."', state='".$state."', town='".$town."', zip='".$zip."', email='".$email."' WHERE id=".$userid."") or die(mysql_error()); }//IF ($_POST['update']=="Update")
  5. Hi, I want to update user information in the database but it doesn't do anything. No data entered upon form submission. Please anyone if you can help would be great. Thank you. <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $host = "";//edited out $database = ""; $username = ""; $password = ""; $tbl_name = "users"; $link = mysqli_connect($host, $username, $password); $conn = mysql_connect($host, $username, $password) or die("Could not connect: " . mysql_error()); mysql_select_db($database); session_start(); IF (isset($_SESSION['userid'])){ $userid=$_SESSION['userid']; echo $userid; } //$currentUser = $_SESSION['myusername']; //do some cleanup// IF (isset($_POST['submit'])){ $first = $_POST['first']; $last = $_POST['last']; $dob = $_POST['dob']; $gender = $_POST['gender']; $country = $_POST['country']; $state = $_POST['state']; $town = $_POST['town']; $zip = $_POST['zip']; $email = $_POST['email']; $first = mysql_real_escape_string( '$first'); $last = mysql_real_escape_string( '$last'); $dob = mysql_real_escape_string( '$dob'); $gender = mysql_real_escape_string( '$gender'); $country = mysql_real_escape_string( '$country'); $state = mysql_real_escape_string( '$state'); $town = mysql_real_escape_string( '$town'); $zip = mysql_real_escape_string( '$zip'); $email = mysql_real_escape_string( '$email'); }; IF (isset($_SESSION['userid'])){ $userid=$_SESSION['userid']; } ELSE{ $getuserid=mysql_query ("SELECT id FROM users ORDER BY id DESC limit 1") or die(mysql_error()); WHILE ($gtuserid = mysql_fetch_array($getuserid)) { $theuserid=$gtuserid['id']; $userid=$theuserid; $_SESSION['userid']=$theuserid; $userid=$_SESSION['userid']; }//$getuserid }// IF ELSE (isset($_SESSION['userid'])) /////UPDATE SECTION///// IF (isset($_POST['submit'])){ mysql_query ( "UPDATE users SET firstname='$first', lastname='$last', dob = '$dob', gender='$gender', country='$country', state='$state', town='$town', zip='$zip', email='$email' WHERE id=$userid") or die(mysql_error()); }//IF ($_POST['update']=="Update") ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Connection</title> <style type="text/css"> body { font-family:Calibri; font-size:1em; } .title { font-size:1.6em; font-weight:strong; } .links a{ font-size::1.2em; text-decoration:none; } .links a:hover{ font-size::1.2em; color:#0066FF; text-decoration:none; } </style> </head> <body> <p><span class="title">Add your personal information/span></p> <form action="thebeast.php" method="post"> <p> <input type="text" name="first" size="20" id="first" /> First name<br /> <input type="text" name="last" size="20" id="name" /> Last name<br /> <input name="dob" type="text" size="20" id="dob" ; } ?> Date of Birth<br /> <input type="text" name="gender" size="20" id="gender" /> Gender <br /> <input type="text" name="country" size="20" id="country" /> Country<br /> <input type="text" name="state" size="20" id="state" /> State<br /> <input type="text" name="town" size="20" id="town" /> Town<br /> <input type="text" name="zip" size="20" id="zip" /> Zip Code<br /> <input type="text" name="email" size="40" id="email" /> Email<br /> <br /> <input type="submit" name="submit" value="Add your information" /> </form> </body> </html>
  6. ok thank you, I will focus on learning that language and not get over my head. I think it is like learning English, I was trying to form whole paragraphs, and then , not knowing how, was looking up tutorials on "how to write paragraphs" I think that is not the way. also , does it matter which you do first, the php and mysql, or the site and all the graphics, then the php and mysql?
  7. Hi, I have been looking up tutorials but find most of them are not relevant to what I am doing such as doing a php search, but not knowing how to filter out words. I was wondering, how much of all of your solutions come from your mastery of the php language, and how much comes from tutorials you have seen? A percentage would be good for both if you can for me. Ideally I would not have to look at any tutorials as I find it to be a pain in the A$$. Ok anyone's percentages welcome! any help appreciated. thank you. (this also applies to php and mysql both)
  8. So you don't need money to advertise? You just start telling people about the site?
  9. Pandemikk LOL that is awesome! I am not that smart, but I think I understand it as "if this is checked search, " and then, "if this is checked, search the first and this one". awesome art. it's art. thank you for typing that I really appreciate it. Have a great night/day!! :(
  10. Hi, I was wondering if anyone knows how I might do a search in a database from a form using checkboxes, where the code is like this below please? I want to do a database query like this, if firstname is checked, and gender is checked. I want to find someone in the database with that gender and first name only. If all of them are checked, find all matches to that criteria. I think this might be a lot harder than I describe, but that is what I need to do. like this mysql_query("SELECT users WHERE gender LIKE '%gender%, OR firstname LIKE....." Search the database by: <form action="search.php" method="post"> <p> <input type="checkbox" name="firstname2" size="20" id="firstname2" value="firstname2" /> First Name<br/> <input type="checkbox" name="lastname2" size="20" id="lastname2" value="lastname2" /> Last Name<br/> <input type="checkbox" name="dob2" size="20" id="dob2" value="dob2" /> Date of Birth<br/> <input type="checkbox" name="gender2" size="20" id="gender2" value="gender2" /> Gender<br/> <input type="submit" name="search" value="Search" /> <input type="reset" name="reset" value="reset" /> </form>
  11. thank you. I just made this funny little banning script for people that leave mean messages on my website poll. The poll takes their ip, emails me their message, if it's mean, I log in to my admin part on the site, go to the ban/unban page, and ban the sob. LOL. lots of fun this banning stuff. ooh the power! php is power. LOL
  12. Hi I am having fun making this little banning script, and it gives me the following error, Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /hermes/bosweb/web173/b1739/public_html/banner.php on line 39 I cannot find what is wrong. please any help is greatly appreciated. Below is the code. <?php session_start(); ini_set ("display_errors", "1"); error_reporting(E_ALL); $host = " xxx"; $database = " xxx"; $username = " xxx"; $password = " xxx"; $tbl_name = "members"; $conn = mysql_connect($host, $username, $password) or die("Could not connect: " . mysql_error()); if($conn) { mysql_select_db($database); } else { echo "failed to select database"; } $ip = mysql_real_escape_string($_POST['banip']); $unbanip = mysql_real_escape_string($_POST['unbanip']); $banned=0; $unbanned=0; $message="-"; //THE BANNER SCRIPT PART if($_POST['submit']) { mysql_query("INSERT INTO members (banned) VALUES ('$ip')"); $banned=1; ` $message="You have banished "; } ///////////////THE UNBANNER PART if($_POST['submit2']) { mysql_query("DELETE FROM members WHERE banned = '$unbanip'"); $unbanned=1; $message="You have unbanned this lucky SOB!!"; } ?> <html> <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"> </head> <style type="text/css"> <!-- .style1 { color: #00CC66; font-weight: bold; font-size: larger; } .style2 { color: #FF3300; font-weight: bold; font-size: larger; } --> </style> <body> <form id="banip" method="post" action="banip.php"> <p> </p> <p> </p> <p align="center"><span class="style2"> IP address to Ban</span> <input type="text" name="banip" id="banip"/> <input name="submit" type="submit" id="submit" value="Ban !"/> <input type="reset" id="reset" name="reset"/> <br> <?php echo $message ; ?> </p> </form> <p align="center"><span class="style1"> IP address to UNban</span> <input type="text" name="unbanip" id="unbanip"/> <input name="submit2" type="submit" id="submit2" value="Unban !!"/> <input type="reset" id="reset2" name="reset2"/> </p> </body> </html>
  13. In addition to the user's ip not updating into the database, I cant get the reCaptcha to work. It says "invalid text entered" or something similar when page loads. Here is the code. relating to the captcha <?php if($_POST['submit']) { $currentPoster = $_SERVER['REMOTE_ADDR']; // get ip of visitor $query = mysql_query("SELECT * FROM members WHERE poster = '$currentPoster'"); //check DB for user ip if (mysql_num_rows($query) > 0) //if ip exists, user already posted { $error=1; //this is t o set if error message echoes or not. $errorMessage=" You already posted to this poll"; // echo error to the multiple post prick//echoed out below } else { $query2 = mysql_query("INSERT INTO members(poster) VALUES ('$currentPoster')");// insert new ip into DB $email_from = ' info POLL'; // email information $email_subject = " OLL RESPONDER"; $email_body = "You have received a new poll message from the user ip address of $currentPoster.\n". "Here is the message:\n $userfeedback"; //////////////////////////////////////////////////////////////////////// //SEND THE EMAIL $to = " 1@hotmail.com"; //email headers $headers = "From: $email_from \r\n"; $headers .= "Reply-To: no one \r\n"; mail($to,$email_subject,$email_body,$headers);// sends off the final email. $error=0; $goodmessage="Thank you for your feedback!"; } } ?> <form id="userfeedback" method="post" action="index.php"> <p> <textarea name="userfeedback" id="userfeedback" cols="45" rows="5"></textarea> <?php require_once('recaptchalib.php'); $publickey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // RECAPTCHA echo recaptcha_get_html($publickey);?> <input type="submit" id="submit" name="submit"/> <input type="reset" id="reset" name="reset"/> </p> </form> <br/> <?php if($error=1) { echo $errorMessage; }else { echo $goodmessage; } require_once('recaptchalib.php'); $privatekey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } ?>
  14. thank you for list. It is more of a theoretical guide to php programming. I was hoping to get specific projects like "chat box", then "forum", etc. But I cannot find such a list on google. I do have the choice of going back to my really thick php mysql book and reading the whole thing, THEN trying to make my own projects based on my knowledge of the language from the book. Usually I bring some knowledge to the table, create a script, get stuck, come here for answers, and repeat. DO you suggest any steps that I go through to get proficient at php and mysql? I was thinking this order 1- Go back to the book and read the whole thing 2-come up with projects out of my head instead of googling for projects which isn't working anyway 3-come to phpfreaks or google the mistakes when problems. Please let me know what you think. Thank you.
  15. EDIT, CORRECTION- IT WENT TO MY JUNKMAIL. HOW DO I PREVENT THAT? ALSO, IT DID NOT PUT THE USER'S IP IN THE 'POSTER' FIELD IN DB SO I CAN PREVENT MULTIPLE POSTS PER PERSON. Hi, I went over the code and looks good to me, I put the "poster" field in my Members table. Everything looks good, my page loads with no errors, but the email never gets sent upon submitting the form "user poll" here is the relevant code, please any help greatly appreciated! thank you. <?php if($_POST['submit']) { $currentPoster = $_SERVER['REMOTE_ADDR']; // get ip of visitor $query = mysql_query("SELECT * FROM members WHERE poster = '$currentPoster'"); //check DB for user ip if (mysql_num_rows($query) > 0) //if ip exists, user already posted { $error=1; //this is t o set if error message echoes or not. $errorMessage=" You already posted to this poll"; // echo error to the multiple post prick//echoed out below } else { $query2 = mysql_query("INSERT INTO members(poster) VALUES ('$currentPoster')");// insert new ip into DB $email_from = '.info POLL'; // email information $email_subject = " POLL RESPONDER"; $email_body = "You have received a new poll message from the user ip address of $currentPoster.\n". "Here is the message:\n $userfeedback"; //////////////////////////////////////////////////////////////////////// //SEND THE EMAIL $to = "xxxx@hotmail.com"; //email headers $headers = "From: $email_from \r\n"; $headers .= "Reply-To: no one \r\n"; mail($to,$email_subject,$email_body,$headers);// sends off the final email. $error=0; $goodmessage="Thank you for your feedback!"; } } ?> <form id="userfeedback" method="post" action="index.php"> <p> <textarea name="userfeedback" id="userfeedback" cols="45" rows="5"></textarea> <input type="submit" id="submit" name="submit"/> <input type="reset" id="reset" name="reset"/> </p> </form> <br/> <?php if($error=1) { echo $errorMessage; }else { echo $goodmessage; } ?>
  16. Can anyone please post on here a list of their beginning projects in order if you can remember them? PLease, I am googling all over the place and getting nothing but newbie tutorials. I need projects in step by step increasing difficulty. Please. Thanks.
  17. thank you. Was that an "online auction" and what does "staff management" app do please?
  18. Thanks. I saw some tutorials there. I am more interested in what projects you did in the order that you did them if you remember, or can pm me or post them. Depending on how long the list is. If you can that would be great. thanks. Then I can just google the tutorials of the projects you did. the important thing is the names of the projects you did in order. please. thanks.
  19. Hi , I am having trouble learning php and mysql. The books only teach me the letters, not the sentences. Please if anyone knows of mysql projects I can do in order of difficulty from newbie to advanced I would GREATLY appreciate it because I have no roadmap for learning. I don't know what I can do with database php applications, and I need them to be incrementally harder so I can learn faster. Please if anyone has an archive of projects that they did, you can pm me here with what they are or you can post them here please. This is the most important thing I need to learn right now, as I literally am lost in the vast sea of websites on this or that tutorial, with no clear logical forward direction in a hierarchy. Please any help greatly appreciated. Thank you! The apps should be database driven as I love database driven apps they are awesome and fun.
  20. awesome thanks very much for taking the time to help me out with that code as I would not have come up with it on my own. I will see how it does, at least I know what I should be doing now. I have to work on my logic skills , and get more creative with applying what I already know. Thanks very much for your help! :)
×
×
  • 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.