Jump to content

fLaVV

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

About fLaVV

  • Birthday 06/27/1988

Profile Information

  • Gender
    Male
  • Location
    USA

fLaVV's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. What I'm trying to do here is make it when you view the page, the two textboxes (one is username, other is password) have default values for them, they would be Username and Password. I currently have them where when you click in the textfields, the default values are removed and the style of the textfield changes. Now the problem I am having is making the password box display "Password" until the user focuses on the box, then it will remove "Password" (making the field blank) then when a user starts typing the password, displaying it in asterix (******). I have both of these functions working on there own, but cannot seem to get them to work together, here is the code I am currently using: <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> function changeBox() { document.getElementById('div1').style.display='none'; document.getElementById('div2').style.display=''; document.getElementById('password').focus(); } function restoreBox() { if(document.getElementById('password').value=='') { document.getElementById('div1').style.display=''; document.getElementById('div2').style.display='none'; } } $(document).ready(function() { $('input[type="text"]').addClass("idleField"); $('input[type="text"]').focus(function() { $(this).removeClass("idleField").addClass("focusField"); if (this.value == this.defaultValue){ this.value = ''; } if(this.value != this.defaultValue){ this.select(); } }); $('input[type="text"]').blur(function() { $(this).removeClass("focusField").addClass("idleField"); if ($.trim(this.value == '')){ this.value = (this.defaultValue ? this.defaultValue : ''); } }); }); --> </script> And the HTML for the forms: <form action="login.php" method="post"> <center> <label for="username"></label> <input name="username" id="username" class="textfield" type="text" value="" size="20" maxlength="20" /> <br /> <div id="div1"> <input name="pass_temp" class="textfield" type="text" value="Password" size="20" maxlength="20" onfocus="changeBox()" /> </div> <div id="div2" style="display:none"> <input name="password" class="textfield" id="password" type="password" value="" size="20" maxlength="20" onBlur="restoreBox()" /> </div> <br /> <input name="submit" type="submit" class="button" id="submit" value="Log In" /> <input name="reset" type="reset" class="button" id="reset" value="Reset" /> </center></form> the problem is the password field. If i take the focus script out, when i click in the field "Password" will disappear, and any entered text will become ******. However when I add the focus part in, it will only display "pass_temp" field (cause its a textfield) and clicking in it, no longer changes the text to ***** So my question would be, how can I make the password field change when focused and at the sametime, whatever is entered into the field, will still be ****** Here is the complete HTML: <!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>Fragged Out :: When You All Fragged Out!</title> <style type="text/css"> <!-- body,td,th { color: #FFFFFF; } body { background-color: #232323; margin-left: 0px; margin-top: 0px; } .textfield { font-family: Verdana, Arial, Helvetica, sans-serif; background-color: #666666; border: thin dashed #000000; font-size: 12px; text-align: center; color: #FFFFFF; font-weight: bold; } .button { background-color: #666666; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #FFFFFF; border: thin solid #000000; } .focusField{ border: thin dashed #000000; background:#999999; color: #000000; } .idleField{ background:#333333; color: #6F6F6F; border: thin dashed #000000; } td.off { } td.on { background: #333333; } --> </style> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> <!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } function changeBox() { document.getElementById('div1').style.display='none'; document.getElementById('div2').style.display=''; document.getElementById('password').focus(); } function restoreBox() { if(document.getElementById('password').value=='') { document.getElementById('div1').style.display=''; document.getElementById('div2').style.display='none'; } } $(document).ready(function() { $('input[type="text"]').addClass("idleField"); $('input[type="text"]').focus(function() { $(this).removeClass("idleField").addClass("focusField"); if (this.value == this.defaultValue){ this.value = ''; } if(this.value != this.defaultValue){ this.select(); } }); $('input[type="text"]').blur(function() { $(this).removeClass("focusField").addClass("idleField"); if ($.trim(this.value == '')){ this.value = (this.defaultValue ? this.defaultValue : ''); } }); }); --> </script> </head><body onload="MM_preloadImages('images/home_over.jpg','images/forums_over.jpg','images/contacts_over.jpg','images/usercp_over.jpg','images/downloads_over.jpg','images/members_over.jpg')"> <table width="951" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><img src="images/header.jpg" width="951" height="173" /></td> </tr> <tr> <td><img src="images/nav_left.jpg" width="49" height="66" /><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','images/home_over.jpg',1)"><img src="images/home.jpg" alt="Home" name="home" width="100" height="66" border="0" id="home" /></a><a href="forums.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('forums','','images/forums_over.jpg',1)"><img src="images/forums.jpg" alt="Forums" name="forums" width="124" height="66" border="0" id="forums" /></a><a href="contact.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contact','','images/contacts_over.jpg',1)"><img src="images/contacts.jpg" alt="Contact Staff" name="contact" width="144" height="66" border="0" id="contact" /></a><a href="usercp.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('usercp','','images/usercp_over.jpg',1)"><img src="images/usercp.jpg" alt="User Control Panel" name="usercp" width="172" height="66" border="0" id="usercp" /></a><a href="downloads.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('downloads','','images/downloads_over.jpg',1)"><img src="images/downloads.jpg" alt="Downloads" name="downloads" width="167" height="66" border="0" id="downloads" /></a><a href="members.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('members','','images/members_over.jpg',1)"><img src="images/members.jpg" alt="Site Members" name="members" width="148" height="66" border="0" id="members" /></a><img src="images/nav_right.jpg" width="47" height="66" /></td> </tr> </table><br /> <table width="951" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" background="images/main_bg2.jpg"> <tr> <td width="1" valign="top"> <table width="951" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="233" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="29" background="images/left_nav.jpg"><div align="center">Navigation Menu</div></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="2"></td> <td valign="top"><table width="98%" border="0" align="center" cellpadding="1" cellspacing="1"> <tr> <td class="off" onmouseover="this.className='on'" onmouseout="this.className='off'">Home</td> </tr> <tr> <td>Downloads</td> </tr> <tr> <td>Members</td> </tr> <tr> <td>Forums</td> </tr> <tr> <td>Contacts</td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td><img src="images/left_nav_footer.jpg" width="233" height="13" /></td> </tr> </table></td> <td width="476" valign="top"> <table width="100%" height="33%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="29" background="images/center_content.jpg"><div align="center">Page Content</div></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="14"></td> <td>Content</td> </tr> </table></td> </tr> <tr> <td><img src="images/center_content_footer.jpg" width="476" height="13" /></td> </tr> </table></td> <td width="242" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="29" background="images/right_nav.jpg"><div align="center">User Login</div></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="14"></td> <td><table width="100%" border="0" cellspacing="1" cellpadding="1"> <tr> <td valign="top"> <form action="login.php" method="post"> <center> <label for="username"></label> <input name="username" id="username" class="textfield" type="text" value="" size="20" maxlength="20" /> <br /> <div id="div1"> <input name="pass_temp" class="textfield" type="text" value="Password" size="20" maxlength="20" onfocus="changeBox()" /> </div> <div id="div2" style="display:none"> <input name="password" class="textfield" id="password" type="password" value="" size="20" maxlength="20" onBlur="restoreBox()" /> </div> <br /> <input name="submit" type="submit" class="button" id="submit" value="Log In" /> <input name="reset" type="reset" class="button" id="reset" value="Reset" /> </center></form> </td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td><img src="images/right_footer.jpg" width="242" height="13" /></td> </tr> </table></td> </tr> </table></td> </tr> </table> </body> </html> I tried to explain the best I could, any help would be grateful. Let me know if you need any more information.
  2. $deduct = mysql_query("UPDATE characters SET gold = gold - " . $amount . " WHERE name = '" . $character . "' AND gold >= '" . $amount . "';"); At the end of the code, it looks like your double closing the query ;");
  3. well if you read the error, it says: This means is throwing an error because it isnt executing properly. Just taking a quick stab, i would guess you need to change UPDATE characters SET gold = gold - " . $amount . " to UPDATE characters SET gold = 'gold - " . $amount . "' I think the "gold - " is messing up the query, maybe by adding the (') it MIGHT work. I am not 100% sure, I am just trying to help ya out, may want some second advice, but thats what i would try first.
  4. Thanks..it all worked...dunno why i didnt try that, but i will look into the other method...ty for all the info
  5. o god...it was so simple...thanks...maybe i should stop making quick scripts in notepad and use my php editor *fLaVV blows dust off maguma studio i will try this and post back...thanks for the help.
  6. To get the cookie information (if its set) you can use $_COOKIE['name'] for example on your login page you would want it to set a cookie $username = $_POST['username']; setcookie ('username', '$username, time() + (60*60*24)); $username is what the user used in the login box. That would set a cookie. Now for finding userid. you would want to try $query = mysql_query("SELECT user_id FROM users WHERE username = '$username'"); Not sure if that is what your looking for but thats how I would do it.
  7. What I am trying to do is display members that are in a certain group from my phpbb (group is clan members) and display them in my roster.php file. My script is working fine and displaying the information that I want it to...but for some reason it isn't looping. It is only displaying the first result. Below is the code, sadly this is the only way I know how to do this, so if you guys know of a better way...im open for ideas. <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center"><strong>Username:</strong></td> <td align="center"><strong>Email:</strong></td> <td align="center"><strong>Rank:</strong></td> </tr> <? $connection = mysql_connect("localhost","username","password"); mysql_select_db("database"); $urfcheck = mysql_query("SELECT * FROM phpbb_user_group WHERE group_id = '12'"); while ($row = mysql_fetch_array($urfcheck)){ $user = $row['user_id']; } $getrank = mysql_query("SELECT * FROM phpbb_xdata_data WHERE user_id = '$user'"); while ($row = mysql_fetch_array($getrank)){ $rank = $row['xdata_value']; } $grabinfo = mysql_query("SELECT username FROM phpbb_users WHERE user_id = '$user'"); while ($row = mysql_fetch_array($grabinfo)){ $username = $row['username']; echo "<tr> <td align=center>$username</td> <td align=center><a href=forums/profile.php?mode=viewprofile&u=$user>Click Here</a></td> <td align=center>$rank</td> </tr> </table>"; } mysql_close($connection); ?>
  8. Omg...i feel like such a n00b now.../cry...thanks for the fast replys didnt mean to bother u all with such a stupid error...Really am sorry, but thanks again. Thanks cooldude, your name says it all ...Yea i dont know why I didnt put that in..also thank you chigley for proving that i cant spell...but now I know to make sure i spell INSERT and not INTERT
  9. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTERT into serach_templates (id, name, serial, info, style, view, download, ima' at line 1
  10. I get no errors, but when I click submit, the information doesnt show up in the database. <? if($_POST['submit']){ include("db.php"); $name = $_POST['name']; $serial = $_POST['serial']; $info = $_POST['info']; $style = $_POST['style']; $view = $_POST['view']; $download = $_POST['dlink']; $image = $_POST['vlink']; mysql_query("INTERT into serach_templates (id, name, serial, info, style, view, download, image)". "VALUES ('NULL', '$name', '$serial', '$info', '$style', '$view', '$download', '$image')"); echo "Results entered!"; } else { ?> <form action="addtemplate.php" method="post"> <table width="433" border="0" cellpadding="0" cellspacing="0"> <tr> <td>Template Name:</td> <td> <input type="text" name="name" id="name" /></td> </tr> <tr> <td>Template Serial:</td> <td> <input type="text" name="serial" id="serial" /></td> </tr> <tr> <td>Information:</td> <td> <textarea name="info" id="info" cols="45" rows="5"></textarea></td> </tr> <tr> <td>Image URL:</td> <td> <input type="text" name="url" id="url" /></td> </tr> <tr> <td>Download Link:</td> <td> <input type="text" name="dlink" id="dlink" /></td> </tr> <tr> <td>View Link</td> <td> <input type="text" name="vlink" id="vlink" /></td> </tr> <tr> <td>Style:</td> <td><select name="style" id="style"> <option selected="selected">--Select Style --</option> <option value="clean">Clean</option> <option value="dark">Dark</option> <option value="light">Light</option> <option value="futuristic">Futuristic</option> <option value="vector">Vector</option> <option value="retro">Retro</option> </select></td> </tr> <tr> <td> </td> <td><div align="center"> <input type="submit" name="submit" id="submit" value="Enter Info" /> </div></td> </tr> </table> </form> <? } ?> Any suggestions?
  11. Sorry, couldnt remember the sytax for the code, tried to edit post but cant find it ...ill give that a try and see if it works. Thanks I tried that and get the same results, saying there are no results found and yet i know there is something in the row on that table.
  12. Hello, I am tryin to make a PHP script that searches a template database for eathier the name, serial or style. The problem I am having is when i enter the Name for a test, it doesn't bring up any result. I have information entered into the database, but when i type in Google in the name field, it doesnt find the row in the database that contains Google.com. Here is the code. <? $cnx = mysql_connect('localhost', 'flaw_root', '****') or die ("Could not connect"); mysql_select_db('flaw', $cnx) or die (mysql_error()); ?> <form action="search.php" method="POST"> <table width="725" border="1" cellpadding="0" cellspacing="0"> <tr> <td width="222">Name:</td> <td width="228">Serial:</td> <td width="205">Style:</td> <td width="60"> </td> </tr> <tr> <td><input type="text" name="name" id="name" /></td> <td> <input type="text" name="serial" id="serial" /> </td> <td> <select name="style" id="style"> <option selected="selected">--Select Style --</option> <option value="clean">Clean</option> <option value="dark">Dark</option> <option value="light">Light</option> <option value="futuristic">Futuristic</option> <option value="vector">Vector</option> <option value="retro">Retro</option> </select> </td> <td> <input type="hidden" name="search" value="true"> <input type="submit" name="submit" id="submit" value="Search!" /> </td> </tr> </table> </form> <? if($_POST['search'] == "true"){ $name = $_POST['name']; $serial = $_POST['serial']; $style = $_POST['style']; $sql = "SELECT * FROM mytable WHERE name LIKE '% .$name. %' OR serial LIKE '$serial' OR style LIKE '$style' ORDER BY mytable_id DESC"; $query = mysql_query($sql) or die(mysql_error()); $row_sql = mysql_fetch_assoc($query); $total = mysql_num_rows($query); if($total>0) { while ($row_sql = mysql_fetch_assoc($query)) { //echo out the results echo ''.$row_sql['name'].'<br />'.$row_sql['style'].''; } } else { echo "No results to display"; } } ?> sorry to take your time.
×
×
  • 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.