Jump to content

Minimeallolla

Members
  • Posts

    197
  • Joined

  • Last visited

    Never

Everything posted by Minimeallolla

  1. They are called when the form is submitted <div id="regform"><form name="input" action="Registration.php" method="get"> Username: <input type="text" name="Username" value="Username" onFocus="this.value=''"/><br /> Password: <input type="password" name="Password"/><br /> Email: <input type="text" name="Email" value="Enter Email" onFocus="this.value=''"/><br /> <input type="submit" name="Submit" value="Register" /><br /> </div></form> you mean put: <?php if ($login_success == true) { print "$login_msg"; } ?> in the html form if i want to display a message for a few seconds before they get redirected?
  2. All criticism/suggestions/improvements appreciated Registration.php <?php $con = mysql_connect("localhost","","") or die(mysql_error()); mysql_select_db('Users'); if(isset($_COOKIE['ID_my_site'])) { $cookie_username = mysql_real_escape_string(filter_input(INPUT_COOKIE, 'ID_', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); $cookie_password = sha1($_COOKIE['Key_']); $cookie_check = mysql_query("SELECT * FROM Users WHERE username = '$cookie_username'") or die(mysql_error()); $cookie_results = mysql_fetch_array($cookie_check); if ($cookie_password == $cookie_results['Password']) { echo "<div id=\"login_msg\">You are already logged on. Redirecting...</div><br />" && header("location:/index.php"); } } if(isset($_POST['submit'])) { $Username = mysql_real_escape_string(filter_input(INPUT_POST, 'Username', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); $Email = mysql_real_escape_string(filter_input(INPUT_POST, 'Email', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); $Password = sha1($_POST['Password']); $Password2 = sha1($_POST['Password2']); if (!$Username | !$Email | !$Password | !$Passord2) { echo "<div id=\"error_msg\">You did not complete all of the required fields, please try again.</div><br />"; } if ($Password != $Password2) { echo "<div id=\"error_msg\">Your passwords do not match, please try again.</div><br />"; } $check_username = mysql_query("SELECT * FROM Users WHERE (Username = $Username)"); $result_username = mysql_fetch_row($check_username); $check_email = mysql_query("SELECT * FROM Users WHERE (Email = $Email)"); $result_email = mysql_fetch_row($check_email); if ($result_username == true) { echo "<div id=\"error_msg\">The Username: '$Username', already exists. Please enter another username.</div><br />"; } if ($result_email == true) { echo "<div id=\"error_msg\">The Email Adress: '$Email', is already in our Database.</div><br />"; } $sql = "INSERT INTO Users (Id, Username, Email, Password) VALUES ('', '$Username','$Email','$Password')"; $add_member = mysql_query($sql) or die(mysql_error()); if (mysql_query($add_member)) { $week = time() + 604800; setcookie(ID_, $_POST['Username'], $week); setcookie(Key_, $_POST['Password'], $week); echo "<div id=\"login_msg\">Successfully added to our Database.</div><br />" && header ("location:/Login.php"); } else { echo "<div id=\"error_msg\">Invalid input.</div><br />"; } } ?> Login.php <?php include("db.php"); if(isset($_COOKIE['ID_my_site'])) { $cookie_username = mysql_real_escape_string(filter_input(INPUT_COOKIE, 'ID_', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); $cookie_password = sha1($_COOKIE['Key_']); $cookie_check = mysql_query("SELECT * FROM Users WHERE username = '$cookie_username'") or die(mysql_error()); $cookie_results = mysql_fetch_array($cookie_check); if ($cookie_password == $cookie_results['Password']) { echo "<div id=\"login_msg\">You are already logged on. Redirecting...</div><br />" && header("location:/index.php"); } } if(isset($_POST['submit'])) { $Username = mysql_real_escape_string(filter_input(INPUT_POST, 'Username', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); $Password = sha1($_POST['Password']); if (!$Username | !$Password) { echo "<div id=\"error_msg\">You did not complete all of the required fields, please try again.</div><br />"; } $sql = "SELECT * FROM Users WHERE (Username, Password) = ('$Username', '$Password')"; $db_check = mysql_num_rows($sql) or die(mysql_error()); if (mysql_query($db_check)) { $week = time() + 604800; setcookie(ID_, $cookie_username, $week); setcookie(Key_, $cookie_password, $week); echo "<div id=\"login_msg\">Successfully Logged In.</div><br />" && header ("location:/index.php"); } elseif (($Username | $Password) != $db_check) { echo "<div id=\"error_msg\">Invalid username or password, please try again.</div><br />"; } } ?> Logout.php <?php include("db.php"); if(isset($_COOKIE['ID_my_site'])) { $cookie_username = mysql_real_escape_string(filter_input(INPUT_COOKIE, 'ID_', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); $cookie_password = sha1($_COOKIE['Key_']); $cookie_check = mysql_query("SELECT * FROM Users WHERE username = '$cookie_username'") or die(mysql_error()); $cookie_results = mysql_fetch_array($cookie_check); if ($cookie_password != $cookie_results['Password']) { header("location:/login.php"); } else { $past = time() - 604800; setcookie(ID_, gone, $past); setcookie(Key_, gone, $past); echo "<div id=\"error_msg\">Sucessfully logged out. Good Bye!</div><br />" && header ("location:/login.php"); } } ?>
  3. Oh ok thanks. So it wouldn't affect the code's functionality if it were removed, or does it have to be there to run properly? I don't really see the point of using it, although I will.
  4. Ok thanks everyone. I'm getting free web hosting through the school which should be good. btw. I understad all of your code except this "[strtolower($_POST['item'])" I've never used or learnt 'strtolower'. Sorry to seem a pain but do you think you could give me a quick run down?
  5. Wow that is pretty amazing code right there compared to mine. I'm obviously starting out but oneday I want to code as well as you can. A few of those errors were merely stupid mistakes. I'm using a school laptop that can't run php or test it, so I practically use notepad without testing.
  6. This is just my software assignment. We have to create a functioning vending machine. How does it look so far? <!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>Vending Machine Assignment</title> <link href="vending.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="vending_machine_base"> <img src="vending_machine_base.gif" alt="Vending Machine Base" title="Vending Machine Base" /> </div> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <p>Coke<input type="radio" name="item" value="Coke" /></p> <p>Sprite<input type="radio" name="item" value="Sprite" /></p> <p>Fanta<input type="radio" name="item" value="Fanta" /></p> <input type="text" size="15" name="quantity" value="Enter quantity here" /> $<input type="text" value="Enter your financial balance." name="credit_input" size="23" /> <input type="submit" value="Submit" /> </form> <?php error_reporting(E_ALL); // Cost of items $coke_price = "1.25"; $sprite_price = "1.50"; $fanta_price = "1.75"; // Quantity of items $coke_quantity = "7"; $sprite_quantity = "5"; $fanta_quantity = "3"; // Selected radio button into variable $selected_item = $_POST['item']; // Credit into variable $credit = $_POST['credit_input']; // If funds are less than price, dispay error message if (($_POST['submit']) && ($selected_radio = 'coke') && ($credit >= $coke_price)) { echo "You have purchased a $selected_item!"; } else { echo "You do not have sufficient funds to purchase a $selected_item."; } if (($_POST['submit']) && ($selected_radio = 'sprite') && ($credit >= $sprite_price)) { echo "You have purchased a $selected_item!"; } else { echo "You do not have sufficient funds to purchase a $selected_item."; } if (($_POST['submit']) && ($selected_radio = 'fanta') && ($credit >= $fanta_price)) { echo "You have purchased a $selected_item!"; } else { echo "You do not have sufficient funds to purchase a $selected_item."; } // Item quantity if (($_POST['submit']) && ($coke_quantity = 0)) { echo ""; } else { echo "Coke resources depleted."; } if (($_POST['submit']) && ($sprite_quantity = 0)) { echo ""; } else { echo "Sprite resources depleted."; } if (($_POST['submit']) && ($fanta_quantity = 0)) { echo ""; } else { echo "Fanta resources depleted."; } // Item cost subtracted from credit if (($coke_quantity >= 1) && ($credit >= $coke_price)) { $coke_price - $credit; } if (($sprite_quantity >= 1) && ($credit >= $sprite_price)) { $sprite_price - $credit; } if (($fanta_quantity >= 1) && ($credit >= $fanta_price)) { $fanta_price - $credit; } // Funds available echo "Your current funds accumlate to $credit "; ?> </body> </html>
  7. DreamWeaver starts some fonts in the font-family with capitals eg (font-family: "Times New Roman", Times, serif;) I was told to never use uppercase in Css because "A" and "a" are not the same. Just wondering if this is an error within Dreamweaver or if i was mislead. (I've noticed W3schools starts them with capitals aswell) Also, "Times New Roman" is in double quotes because of the spaces, right?
  8. I don't understand what you're asking.
  9. Long story, lets just say I very limited internet access, for now anyways. I only wanted the include function, it's not like that function along requires a whole server. I guess I can go without php for a while lol. Thanks anyway though
  10. Here is the working script if anybody ever wants it. (all codes shown are vital for a working code) <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <a class="image-expand" style="cursor: pointer" onclick="toggleSize(this)"> <img src="Pics/roflcopter.gif" /> $(document).ready(function(){ // default width and height to 75px $("a.image-expand img").css({'height':'75px', 'width':'75px'}); }); function toggleSize(_var_) { image = $(_var_).children("img"); if(($(image).css("height") == "75px") && ($(image).css("height") == "75px")) { $(image).css({'height':'auto', 'width':'auto'}); } else { $(image).css({'height':'75px', 'width':'75px'}); } }
  11. I have come across a script that sets all images by default to 75x75pixels and clicking toggles between original size and back to 75x75px only problem is each image is in the "a.image-expand img" class. therefor when one image is expanded they all expand.. -.- any way to only expand selected image? $(document).ready(function(){ // default width and height to 75px $("a.image-expand img").css({'height':'75px', 'width':'75px'}); // Click function (toggle) $("a.image-expand").click(function(){ if(($("a.image-expand img").css("height") == "75px") && ($("a.image-expand img").css("height") == "75px")) { $("a.image-expand img").css({'height':'auto', 'width':'auto'}); } else { $("a.image-expand img").css({'height':'75px', 'width':'75px'}); } }); });
  12. Only if it's portable \= and thorpe. I only wanted to use the include function for now untill I do have further access. Just to neaten up my files lol.
  13. @haku, That is not what I want to achieve. That is all the code you need to see what I'm trying to do. Onclick it will expand the image from the default set 75x75pixels to auto (100%) What I'm trying to do is revert back to its default size onclick. <!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>Funny Pictures</title> <script type="text/javascript" src="Interactive.js"></script> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <a class="image" onClick="this.className = 'new_class'; return false;"><img src="Pics/batman.png" alt="I'm Teh Batman!" /></a> </body> </html> Javascript onClick="this.className = 'image-expand'"; Css. a.image img { width:75x; height:75px; } a.image-expand { border:0; position:center; width:auto; height:auto; z-index:10000; }
  14. try this alternative explaination.. http://pastebin.com/BbLdRCGL
  15. .image-hover { border:0; position:center; width:auto; height:auto; z-index:10000; } a.image img { width:75x; height:75px; } a.image:hover img { border:0; position:center; width:auto; height:auto; z-index:10000; } Is there a way of turning those hover functions into a javascript onclick function?
  16. Oh. I'm on a DET laptop which is highly restricted -.- wamp and xammp cannot be installed \= My main laptop recently broke and use this because it's small, portable and easy to code on.
  17. and the index is .html ? I'm trying to put html code into a php file and then on my index.html call on that php file so my index.html isn't jammed with codes. Sorry to sound like such a noob lol \= So I can't use the include function without hosting it as a proper website?
  18. Is it possible to make it so if you click on a <a href> the information such as the name or link changes the <title> of the page and replaces existing opened <div>s with information from the link or such. eg If i had a list of swf files that were attatched to links how could I display each swf file onclick without redirecting whilst changing the title and content?
  19. Well I currently don't have a server/ftp nor is the site hosted atm. I'm wanting to store abit of html code in another file and then use php in my index to call on that file but it's not working. I havn't used php in a very long time and have forgotten most of it. <?php include ("Drop_Down_Menu.php"); ?> It's not a problem with the file path.
  20. Yeah, i'll stick to using php since the way I intended on using javascript wasn't really interactive, more server like.
×
×
  • 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.