-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
sure <?php include("datatube/dbinfo.inc.php"); mysql_connect($dbhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * from SongList2 where active='1'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<center><H1>What would you like to hear Grant sing?</H1>"; ?> <CENTER> <table border="1" cellspacing="2" cellpadding="3" class="sortable" width="90%" class="sortable"> <TR> <TH valign="top" sortdir="asc">Song Title</TH> <TH valign="top">In the style of</TH> <TH valign="top" width="100">Pace</TH> <TH valign="top" width="100">Length</TH> </TR> <?php $i=0; $total = 0; //ADDED while ($i < $num) { $Active=mysql_result($result,$i,"Active"); $SongTitle=mysql_result($result,$i,"SongTitle"); $ArtistPrimary=mysql_result($result,$i,"ArtistPrimary"); $SongPace=mysql_result($result,$i,"SongPace"); $Minutes=mysql_result($result,$i,"Minutes"); //Added $total = $total + $Minutes; $time = mktime(0, 0, $Minutes); $time = date("i.s",$time); $id=mysql_result($result,$i,"id"); if($SongPace == "") $SongPace = " "; ?> </form> <tr> <TD valign="top"><? echo "$SongTitle"; ?></TD> <TD valign="top"><? echo "$ArtistPrimary"; ?></TD> <TD valign="top"><? echo "$SongPace"; ?></TD> <TD valign="top"><? echo "$time"; ?></TD> </TD> </tr> <?php ++$i; } echo "</table></CENTER>"; $time = mktime(0, 0, $total); $time = date("i.s",$time); echo "<P>Total songs on playlist: $i ($time)</P>"; ?>
-
Humm code should be ok if their on different pages (unless you click back, instead of the link) would need to see the index.php page and know the problem a little better Just better point this out update the code (see below) as your login is vulnerable to an SQL injection exploit (anyone can login as anyone or even change other peoples password, drop the database etc) you could also hash the password (we're come back to that) (seach this forum for MD5 your find a ton of stuff) <?php ob_start(); $host="localhost"; // Host name $username="gameyinc"; // Mysql username $password="*****"; // Mysql password $db_name="gameyinc_members"; // Database name $tbl_name="users"; // Table name $user=$_POST['username']; $link = mysql_connect("$host", "$username", "$password")or die(mysql_error()); mysql_select_db("$db_name")or die("cannot select DB") or die ("Could not connect to mysql because ".mysql_error()); //****Add this $uName = mysql_escape_string($_POST['username']); $uPass = mysql_escape_string($_POST['password']); //**$match = change to this $match = "select id from $tbl_name where username = '$uName' and password = '$uPass';"; $qry = mysql_query($match) or die ("Could not match data because ".mysql_error()); $num_rows = mysql_num_rows($qry); if ($num_rows <= 0) { echo "Sorry, there is no username $username with the specified password.<br>"; echo "<a href=login.html>Try again</a>"; //exit; ..not needed } else { setcookie("loggedin", "TRUE", time()+(3600 * 24)); setcookie("mysite_username", "$user"); echo "You are now logged in!<br>"; echo "Continue to the <a href=\"index.php\">Home</a> Page."; } ob_end_flush(); ?>
-
it will not fix the refesh problem, i am going to guess here but i think your checking the cookie (are they logged in) but only later in the code checking they login details.. ie with the code below if you load login.php?login your get the message but if you refeash it will change to <?php //Section 1 if($_COOKIE['loggedin']) { echo "you are logged in"; }else{ echo "your not logged in"; } //section2 if(isset($_GET['logout'])) { $_COOKIE['loggedin'] = false; } if(isset($_GET['login'])) { $_COOKIE['loggedin'] = true; } ?> But if you move section 1 under section 2 it will work ie <?php //section2 if(isset($_GET['logout'])) { $_COOKIE['loggedin'] = false; } if(isset($_GET['login'])) { $_COOKIE['loggedin'] = true; } //Section 1 if($_COOKIE['loggedin']) { echo "you are logged in"; }else{ echo "your not logged in"; } ?> so i think you need to find the part where to check the login and move it up..
-
Shouldn't be a major problem switching, just need session_start(); at the start and change $_COOKIE AND $HTTP_COOKIE_VARS to $_SESSION
-
try (had a quick look) <div class="tmenu"> <b><a class="add" href="index.php">Home</a></b> <a href="store/index.html">Store</a> <?php if (!isset($_COOKIE['loggedin'])) { echo "<a href=\"register.html\">Register</a> <a href=\"login.html\">Login</a>"; }else{ $mysite_username = $_COOKIE["mysite_username"]; echo "<a href=\"logout.php\">Logout</a> <a href=\"usercp/index.html\">UserCP</a>"; } ?> edit: Opps moved a line down! i assume that how its got to be
-
please don't double post http://www.phpfreaks.com/forums/index.php/topic,189510.msg850118.html#msg850118 EDIT: LOCKED BY WILDTEEN88
-
i did say that 3 times!
-
try this $email=$row['email']; echo '<a href="mailto:$email">'.$email.'</a>'; removed a space and added a dot (.)
-
have you tried? $db_name="webusername_members"; // Database name replacing webusername with your username ? as you have no underscore on the name! EDIT: if your getting "cannot select DB" then the DB name is wrong
-
check the database name.. please note some Host will prefix your database name IE the database "Members" could be "gameyin_Members" EDIT: infact some also do the same with the username
-
the error is "cannot connect"; but change $link = mysql_connect("$host", "$username", "$password")or die("cannot connect"); to this $link = mysql_connect("$host", "$username", "$password")or die(mysql_error()); now whats the error ?
-
why not store them in seconds and when you list them do something like this <?php #SELECT Name, Seconds FROM MusicList; $total = 0; //loop $total = $total + $row['Seconds']; $time = mktime(0, 0, $row['Seconds']); $time = date("i.s",$time); echo $row['Name']." - ".$time; //end loop $time = mktime(0, 0, $total); $time = date("i.s",$time); echo "Total Time = $time"; ?>
-
in the php script that handles the posted data, add $_SESSION['id'] = 1; but at the START of that page (before anything else is written to the page) add <?php session_start(); ?>
-
App runs very slow when users access the very first webpage
MadTechie replied to guarriman's topic in PHP Coding Help
Yep.. the SWF would do it, check the filesize of everything that loads on the firstpage, maybe clear cache and test, then remove the link to the swf then clear cache and test, yes i mean client/browser cache -
automatically chmod files on a server by using cron
MadTechie replied to dreamwest's topic in PHP Coding Help
yes, use chmod() in a cron job ?? -
I have never heard of one.. as far as i am aware its a manual job as far as i know, if their is a converter your probably need to clean it up manually anyway.
-
App runs very slow when users access the very first webpage
MadTechie replied to guarriman's topic in PHP Coding Help
Doesn't sound like php issule to me.. but if it is it should be posted in third party (as its smarty related) to me it sounds like a large file (maybe image) loading into cache, theirs a few other things but i think the large image or connecting to remote files is likely. if you can post a link we could take a look. -
gmail recieves mails sent from php's mail() function, but not yahoo mail
MadTechie replied to obay's topic in PHP Coding Help
yes it closer to the standard used my many mail hosts.. (using: end of line, Message-ID, X-Mailer) note the comment -
gmail recieves mails sent from php's mail() function, but not yahoo mail
MadTechie replied to obay's topic in PHP Coding Help
thats probably because of the of the yahoo's filters (not much you can do) it could be down to the number of emails sent, bad subject, bad domain. alot of sites now say please check your junk/spam folder -
see example here http://www.phpfreaks.com/forums/index.php/topic,188922.msg847244.html#msg847244 UPDATE: try something like this <?php echo "<table border=\"0\">\n<tr>\n"; $c = 4; //Rows $t=0; while ($row = mysql_fetch_assoc($result)) { $t++; if(!($t % $c)) echo "</tr><tr>"; echo "<td>"; echo $row["userid"]; echo $row["fullname"]; echo "</td>"; } if(!($t % $c)) echo "</tr>"; echo "</table>\n"; ?>
-
if the form is not submitting then yes thats the problem try onChange=\"document.brisi_poraki.submit();\" or onChange=\"brisi_poraki.submit();\"
-
just change "sortiraj" to "sort" and if the form is a post change the get's to post!
-
Why you want to do it seam weird but this is how, (i assume you was going to use more than just echo thos is not tested but should work) <?php $DBData = '<p>Anti Passback Violations occur when an individual is not following standard badging procedures for certain sensitive areas.</p><p><?php echo "How are you today?"; ?></p>'; preg_match_all('/<\?(?:php)?(.*)?\?>/m', $DBData, $result, PREG_PATTERN_ORDER); foreach($result[1] as $K => $cmd) { ob_start(); eval($cmd); $str = ob_get_contents(); ob_end_clean(); $cmd = preg_quote($result[0][$K]); $DBData = preg_replace("/$cmd/m", $str, $DBData); } echo $DBData; ?> EDIT: I should really say that a ton of things can go wrong and this code is totally insecure and i wouldn't use it on my own system unless i really really really really had to.. even then i would clean it up and add some security around it, and if you do use this its exploited don't say you want warned!