Jump to content

MarkT

Members
  • Posts

    168
  • Joined

  • Last visited

Posts posted by MarkT

  1. Hello,I'm trying to get my PHP to select the ID from the table 'users' and use it in an SQL query,I've listed my code;

    $id= $_SESSION['id'];$id2 = mysql_query("SELECT * from 'Friends' WHERE 'id1' = '{$id}'"); echo  $id2["id2"] ;?>

    this bit works,but I can't "echo $id2["id2"] ;" the above code does not list the id2 that is listed in the database. Any help appreciated!

  2. Or simply,create an a class in your CSS. a:link{color: #colourcode;background-color: #Colourcode;}a:hover {color: #colourcode;background-color: #Colourcode;}a:active{color: #colourcode;background-color: #Colourcode;}a:visited{color: #colourcode;background-color: #Colourcode;}

    • Like 1
  3. I'm doing a travel blog and want to enable viewers to be able to click on a small image and see a bigger one. I now use an anchor tag with target _blank which causes the large photo to be shown on a separate tab. This, in turn requires the viewer to manually delete the tab(s). I would like to use the method I see on many web pages where the blog page stays visible, but "grayed" out, while the large image is shown in the middle of the window. The user then has to click something (or press Esc key) to get back to the main page. Can anyone guide me in the right direction? TIA,PeteP.S. I'm using HTML5, jQuery (just a beginner) and js.
    PrettyPhoto It's what most people use, and it allows a selection of different options.
  4. Glad you got it positioned correctly. I like to add that you are really using was too much css to get this kind of results. Not sure why border-radius is being used. Your #bar background is set to black but you have it called in a few other places as well which is redundant. You also need to apply css reset forcing all tags to zero out the default margins and padding. * {margin: 0; padding: 0;} Here's a stripped down css version that you may want to use:
    * {margin: 0;padding: 0;}#bar {height: 60px;background-color: #000;position: fixed;padding-left: 2%;padding-right: 2%;width: 96%;}#title h1 {line-height: 60px;color: #DF3A01;padding-right: 20px;}#search {color: #FFF;float: left;line-height: 60px;padding-right: 20px;float: none;width:470px;margin: 0 auto;}#buttons {color: #FFF;float: right;padding-left: 0px;}#buttons ul {line-height: 60px;}#buttons li {border-left: 2px dashed #FE9A2E;padding: 5px 5px 5px 5px;display: inline;}

    Thanks for the stripped down code,Although I haven't used it, it would do the trick. I fixed it using Float:right;
  5. Thanks a lot for your hint MarkT, sure, there are always ways around and currently I don't miss it. It was rather to keep the topic useful for others as well and not only for solving only my "problem". As told, things even they are mentioned as free, are not free. The costs one has to pay back indirectly any way. So that is why I try to get around all additional software even if they could be included in this or that host package.So I try to keep it on the HTML level which is the most used source and simplest on internet I guess.Machines need fuel anyway and not seeing that directly does not mean that such is not used. Its like if you need to cut a little bit of wood and take the high-tech saw and not just use the hand saw next to one. How ever, I am very happy about your care and generous hint. sadhu_sangham_sw.gif
    I don't really understand what you are saying,Fav.CC is Totally Free & Unlimited, the only thing they do is put a small advert on the bottom of your site.Everything else comes FREE. Unlimited Bandwidth/Storage/Db's/Email addresses etc
  6. Post your current code.
    Current Code:
    if(isset($_SESSION['loggedin'])){    die("You are already logged in!<a href='logged.html'> Go</a>");} // That bit of code checks if you are logged in or not, and if you are, you can't log in again!if(isset($_POST['submit'])){   $mail = mysql_real_escape_string($_POST['email']); // The function mysql_real_escape_string() stops hackers!   $name = mysql_real_escape_string($_POST['name']); // The function mysql_real_escape_string() stops hackers!   $pass = mysql_real_escape_string($_POST['password']); // We won't use MD5 encryption here because it is the simple tutorial, if you don't know what MD5 is, dont worry!   $user_id = mysql_query("SELECT id FROM users where 'name' = '{$name}'");   $row1 = mysql_num_rows( $user_id );   $banned = mysql_query("SELECT * FROM bans WHERE 'user_id' = '{$user_id}'");   $row2 = mysql_num_rows( $banned );   $mysql = mysql_query("SELECT * FROM users WHERE name = '{$name}' AND email = '{$mail}' AND password = '{$pass}'"); // This code uses MySQL to get all of the users in the database with that username and password.  if(mysql_num_rows($mysql) < 1)   {	 die("Incorrect Login Details");   } // That snippet checked to see if the number of rows the MySQL query was less than 1, so if it couldn't find a row, the password is incorrect or the user doesn't exist!   elseif(($row2) == 1 )   {   die ("You are currently banned from PitchIT");   }   $_SESSION['loggedin'] = "YES"; // Set it so the user is logged in!   $_SESSION['email'] = $mail; // Make it so the email can be called by $_SESSION['email']   $_SESSION['name'] = $name; // Make it so the username can be called by $_SESSION['name']   die("You are now logged in!   <a href='logged.html'> Go</a>"); // Kill the script here so it doesn't show the login form after you are logged in!} // That bit of code logs you in! The "$_POST['submit']" bit is the submission of the form down below VVecho "<form type='index.html' method='POST'>Name: <br><input type='text' name='name'><br>Email: <br><input type='email' name='email'><br>Password: <br><input type='password' name='password'><br><input type='submit' name='submit' value='Login'></form>";?>

  7. $row1 = mysql_num_rows( $user_id ); Is the line left, with the error, i got rid of the other one. but this one remains, Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/u872116037/public_html/index.html on line 69 You are now logged in! Go
    Alright, I've got rid of those errors.But it's still not saying that I'm banned?
  8. Those errors mean that the queries failed, you can use mysql_error to check for error messages from MySQL.
    $row1 = mysql_num_rows( $user_id ); Is the line left, with the error, i got rid of the other one. but this one remains, Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/u872116037/public_html/index.html on line 69 You are now logged in! Go
  9. Check mysql_num_rows($banned), that function works on a result set, not an array of a single row.
    New code;
    if(isset($_POST['submit'])){   $mail = mysql_real_escape_string($_POST['email']); // The function mysql_real_escape_string() stops hackers!   $name = mysql_real_escape_string($_POST['name']); // The function mysql_real_escape_string() stops hackers!   $pass = mysql_real_escape_string($_POST['password']); // We won't use MD5 encryption here because it is the simple tutorial, if you don't know what MD5 is, dont worry!   $user_id = mysql_query("SELECT 'id' FROM 'users' where 'name' = '{$name}'");LINE 69 -   $row1 = mysql_num_rows( $user_id );   $banned = mysql_query("SELECT * FROM 'bans' WHERE 'user_id' = '{$user_id}'");LINE 71 -   $row2 = mysql_num_rows( $banned );    $mysql = mysql_query("SELECT * FROM users WHERE name = '{$name}' AND email = '{$mail}' AND password = '{$pass}'"); // This code uses MySQL to get all of the users in the database with that username and password.  if(mysql_num_rows($mysql) < 1)   {	 die("Incorrect Login Details");   } // That snippet checked to see if the number of rows the MySQL query was less than 1, so if it couldn't find a row, the password is incorrect or the user doesn't exist!   if($row2 > 0 )   {   die ("You are currently banned from PitchIT");   }   $_SESSION['loggedin'] = "YES"; // Set it so the user is logged in!   $_SESSION['email'] = $mail; // Make it so the email can be called by $_SESSION['email']   $_SESSION['name'] = $name; // Make it so the username can be called by $_SESSION['name']   die("You are now logged in!   <a href='logged.html'> Go</a>"); // Kill the script here so it doesn't show the login form after you are logged in!} // That bit of code logs you in! The "$_POST['submit']" bit is the submission of the form down below VVecho "<form type='index.html' method='POST'>Name: <br><input type='text' name='name'><br>Email: <br><input type='email' name='email'><br>Password: <br><input type='password' name='password'><br><input type='submit' name='submit' value='Login'></form>";?>

    Error when you log in:

    Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/u872116037/public_html/index.html on line 69 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/u872116037/public_html/index.html on line 71 You are now logged in! Go

  10. you aren't doing anything with the result from mysql query, you are testing against a result.http://php.net/manua...mysql-query.phphttp://www.tizag.com.../mysqlquery.php you should use something like fetch_arrayhttp://www.php.net/m...fetch-array.phphttp://www.w3schools...fetch_array.asp that can check the count (length of) to see if it returned N number of results.
    My new code is;
    if(isset($_POST['submit'])){   $mail = mysql_real_escape_string($_POST['email']); // The function mysql_real_escape_string() stops hackers!   $name = mysql_real_escape_string($_POST['name']); // The function mysql_real_escape_string() stops hackers!   $pass = mysql_real_escape_string($_POST['password']); // We won't use MD5 encryption here because it is the simple tutorial, if you don't know what MD5 is, dont worry!   $user_id = mysql_query("SELECT 'id' FROM 'users' where 'name' = '{$name}'");   $row1 = mysql_fetch_array( $user_id );   $banned = mysql_query("SELECT * FROM 'bans' WHERE 'user_id' = '{$row1}'");   $row2 = mysql_fetch_array( $banned );   $mysql = mysql_query("SELECT * FROM users WHERE name = '{$name}' AND email = '{$mail}' AND password = '{$pass}'"); // This code uses MySQL to get all of the users in the database with that username and password.   if(mysql_num_rows($mysql) < 1)   {	 die("Incorrect Login Details");   } // That snippet checked to see if the number of rows the MySQL query was less than 1, so if it couldn't find a row, the password is incorrect or the user doesn't exist!   if(mysql_num_rows($row2) == 1 )   {   die ("You are currently banned from PitchIT");   }   $_SESSION['loggedin'] = "YES"; // Set it so the user is logged in!   $_SESSION['email'] = $mail; // Make it so the email can be called by $_SESSION['email']   $_SESSION['name'] = $name; // Make it so the username can be called by $_SESSION['name']   die("You are now logged in!   <a href='logged.html'> Go</a>"); // Kill the script here so it doesn't show the login form after you are logged in!} // That bit of code logs you in! The "$_POST['submit']" bit is the submission of the form down below VVecho "<form type='index.html' method='POST'>Name: <br><input type='text' name='name'><br>Email: <br><input type='email' name='email'><br>Password: <br><input type='password' name='password'><br><input type='submit' name='submit' value='Login'></form>";?>

    But still not working,Can you explain what I should do with examples of my code please?

  11. The answer is i dont know, maybe its just the html code thats working, obviuosly. So how do i fix this problem, i am running it through my localhost?
    The answer was given above. go onto a different computer, when Xampp is on, and load the address;http://www.{IP OF THE MACHINE YOU'RE HOSTING XAMPP ON}/myfile.php and it'll work.
  12. Hello,I'm creating a login for my new website,I've set up all the db, however I've added a bans table. with the following structure;iduser_idreasonissue_dateexpiry_date and I want the login to check whether the user that wishes to log in, is banned or not. I have the below code, but when I ban myself in the database, it still lets me log in and says "You are now logged in"

    if(isset($_POST['submit'])){   $mail = mysql_real_escape_string($_POST['email']); // The function mysql_real_escape_string() stops hackers!   $name = mysql_real_escape_string($_POST['name']); // The function mysql_real_escape_string() stops hackers!   $pass = mysql_real_escape_string($_POST['password']); // We won't use MD5 encryption here because it is the simple tutorial, if you don't know what MD5 is, dont worry!   $user_id = mysql_query("SELECT id FROM users where name= '{$name}'");   $banned = mysql_query("SELECT * FROM bans WHERE user_id = '{$user_id}'");   $mysql = mysql_query("SELECT * FROM users WHERE name = '{$name}' AND email = '{$mail}' AND password = '{$pass}'"); // This code uses MySQL to get all of the users in the database with that username and password.   if(mysql_num_rows($mysql) < 1)   {	 die("Incorrect Login Details");   } // That snippet checked to see if the number of rows the MySQL query was less than 1, so if it couldn't find a row, the password is incorrect or the user doesn't exist!   if(($banned) == '1' )   {   die ("You are currently banned from PitchIT");   }   $_SESSION['loggedin'] = "YES"; // Set it so the user is logged in!   $_SESSION['email'] = $mail; // Make it so the email can be called by $_SESSION['email']   $_SESSION['name'] = $name; // Make it so the username can be called by $_SESSION['name']   die("You are now logged in!   <a href='logged.html'> Go</a>"); // Kill the script here so it doesn't show the login form after you are logged in!} // That bit of code logs you in! The "$_POST['submit']" bit is the submission of the form down below VVecho "<form type='index.html' method='POST'>Name: <br><input type='text' name='name'><br>Email: <br><input type='email' name='email'><br>Password: <br><input type='password' name='password'><br><input type='submit' name='submit' value='Login'></form>";?>

    Any help appreciated!

  13. Thanks a lot for your advice, Lab theoretical I also would think is such a direction, practical I am really not into php and thought of php might be not supported from the host, it would cause additional cost (direct or indirect, nothing is for free). So if you have a hint or trick to get around such a problem, it would be great. Thought of a big content of pages, maybe such is even handle able with a editor trick with a special "replace" function and to make it on the offline side (not "automatically"). Thanks anyway for your care and hint, Lab. sadhu_sangham_sw.gif
    Use a different free web host?I recommend fav.cc they have PHP installed on free web hosting.
  14. Hello,Sorry I'm experiencing problems with my css,

    #title {width: 200px;height: auto;margin-top: -10px;margin-left: 20px;background-color:#000;border-radius: 2px;color: #DF3A01;}#search {width: 600px;height: auto;color: #FFF;margin-top: 28px;position: absolute;margin-left: 190px;display: inline;}#buttons {width: 300px;height: auto;color: #FFF;margin-top: 28px;position: absolute;margin-right: 30px;display: inline;}#buttons li {border-left: 2px dashed #FE9A2E;padding: 5px 5px 5px 5px;display: inline;}#buttons ul {display: inline;}#bar {margin-left: -15px;margin-right: -15px;margin-top: -12px;width: 110%;height: 50px;background-color: #000;position: fixed;border-radius: 3px;padding-left: 15px;padding-right: 15px;padding-top: 12px;}

    and my html;

    <div id="bar"><div id="title"><h1 color="#FE9A2E" style="float: left;">PitchIT</h1></div><div id="search"><?PHP// Array for Config variables$Config['CanSearch'] = false; // Falseif($Config['CanSearch'] == true){    echo 'form name="search" method="post" action="<?=$PHP_SELF?>"><input type="text" size="50" name="query" placeholder="Enter Search Query Here..." /> by<Select NAME="field"><Option VALUE="name">Name</option><Option VALUE="email">Email</option><Option VALUE="id">ID</option></Select><input type="hidden" name="searching" value="yes" /><input type="submit" name="search" value="Search" /></form>';}else{    echo 'Search Currently Unavailable!';}?></div><div id="buttons"><ul><li>Bob</li><li>Bob</li></ul></div></div>

    But it shows as the image attached below. The bob li's show up in the middle f the search and title.they're meant to be on the far right.... Thanks in advance!all help appreciated!

    post-156097-0-44782600-1369917913_thumb.png

×
×
  • Create New...