Jump to content

brissy_matty

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

brissy_matty's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi All, I have a question - is it possile to import data from a sql file which has been exported from another database without using something like phpmyadmin ? Or must it be done using phpmyadmin. Also is it possible to just export data without having to use phpmyadmin or similar? Matt
  2. Thanks for pointing me in the right direction this is a much better solution i wasnt aware you could actually do something like that. Much appreciated. Matt
  3. Hi All, Getting stuck on a bit of a date problem. I want to display "ACTIVE" if the startdate is the current date or greater then the current date BUT less then or equal to the enddate. Basically to show if an item is active or not within a current date range. $startdate & $enddate both come from a date column in a mysql database. Below is what i thought would have worked... Apparently not.. Any ideas appreciated <?php $startdate=mysql_result($result,$i,"startdate"); $enddate=mysql_result($result,$i,"enddate"); $current=date("Y-m-d"); if ($current <= "$startdate" && $current >= "$enddate") { $status="<font color='green' face='verdana' size='1'>ACTIVE</font>"; } else { $status="<font color='red' face='verdana' size='1'>INACTIVE</font>"; } ?> Thanks Heaps Matt
  4. <?php switch($_POST['guess']) { case "1": //Your code here.... break; } ?>
  5. okay so i am guessing that the only way to get it display all the times where there is an unknown quantity of them - some will have 6 times others will have one or 2 - would be to setp up a loop ?
  6. it's only displaying the last record because when you are "echoing" the output it is outside of the loop - so the loop has finished and its set on the last record. Least thats what i think... your code: $lala = mysql_query("SELECT `cost` FROM `table` WHERE `ID` = '1'"); while ($la = mysql_fetch_row($lala)){ $start = 0; $overall = $start+=$la[0]; } echo("$overall"); would prob be better as: <?php $lala = mysql_query("SELECT `cost` FROM `table` WHERE `ID` = '1'"); $result=mysql_query($lala); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $cost=mysql_result($result,$i,"cost"); echo "$cost<br>"; // If you need to add a zero to the front then just add a 0 before $cost $i++; } ?>
  7. user_check.php <?php include_once("$sitepath/functions.php"); $sql = mysql_query("SELECT * FROM users WHERE username = '$_COOKIE[username]'") OR DIE("Sorry Theres a mysql error."); $row = mysql_fetch_array($sql); $num = mysql_num_rows($sql); //check if username exsists if($num == 0) { print("You must be logged in to veiw this page!<BR>"); login_form(); print("<BR>Lost password?"); lostpass_form(); include("$sitepath/html/footer.php"); exit; } //check cookies exsist elseif($_COOKIE[username]=="" OR $_COOKIE[password]=="") { print("You must be logged in to veiw this page!<BR>"); login_form(); print("<BR>Lost password?"); lostpass_form(); include("$sitepath/html/footer.php"); exit; } //check if password is correct elseif($_COOKIE[password] != $row[password]) { print("You must be logged in to veiw this page!<BR>"); login_form(); print("<BR>Lost password?"); lostpass_form(); include("$sitepath/html/footer.php"); exit; } $username = $_COOKIE[username]; $date = date("U"); $updatelastlogin = mysql_query("UPDATE users SET last_login = '$date' WHERE username = '$_COOKIE[username]'"); $pm = mysql_query("SELECT * FROM im WHERE sentto = '$username' AND status = 'unread'"); $npms = mysql_num_rows($pm); if($npms > 0) { print("<table class='all' width=500><tr><td><a href='$siteurl/pm/index.php'>You Have $npms New Message(s)</a></td></tr></table><BR>"); } ?> Like i said - maybe not the best code but with a little playing around i am sure you can achieve what you want. Some of this stuff won't be relevant to your usage - you will just need to remove things that arent like included headers / footers / nav and any irrelevant database fields. Cheers Matt
  8. loggedin.php <?php include("config.php"); include("$sitepath/html/header.php"); include("user_check.php"); // I normally insert a refresf here if i dont wany to display anything print("Your now logged in fully.<BR><BR>"); include("$sitepath/html/footer.php"); ?>
  9. functions.php <?php function lostpass_form() { global $siteurl,$sitetitle; print(" <form name='form1' method='post' action='$siteurl/lostpw.php?action=lostpass' name='lp_form' onSubmit=\"document.lp_form.lp_submit.disabled=true\"> <table width='100%' border='0' cellspacing='0' cellpadding='4' align='center'> <tr> <td>Email Address</td> <td><input name='email_address' type='text'></td> </tr> <tr> <td> </td> <td><input name='recover' type='hidden' value='recover'> <input type='submit' name='lp_submit' value='Gain The Knowledge Of My Password!'></td> </tr> </table> </form> "); } function login_form() { global $siteurl,$sitetitle,$username; print(" <form action='$siteurl/login.php?action=login' method='post' name='l_form' onSubmit=\"document.l_form.l_submit.disabled=true\"> <table width='50%' border='0' align='center' cellpadding='4' cellspacing='0'> <tr> <td width='22%'>Username</td> <td width='78%'><input name='username' type='text'></td> </tr> <tr> <td>Password</td> <td><input name='password' type='password'></td> </tr> <tr> <td> </td> <td><input type='submit' name='l_submit' value='Login To Mysite!'></td> </tr> </table> </form> "); } ?>
  10. Possibly not the best code in the world but here you go: login.php <?php //Database/Mysql// $dusername = "mysite_username"; //username to connect to database $dpwd = "mysite_password"; //password to accecss mySQL $dhost = "localhost"; //your db host usually localhost $dbname = "mysite_database_1"; //db name to be accessed $conn = mysql_connect("$dhost","$dusername","$dpwd") or die ("Unable to connect to database."); $db=mysql_select_db($dbname,$conn) or die("Unable to connect to database!"); include("functions.php"); if($action==login) { if($_COOKIE[username]=="" AND $_COOKIE[password]=="") { $md5_password = md5($_POST[password]); $sql = mysql_query("SELECT * FROM users WHERE username = '$_POST[username]' AND password = '$md5_password'") OR DIE("Sorry there is a mysql error."); $row = mysql_fetch_array($sql); $numrows = mysql_num_rows($sql); if($_POST[password]=="") { //include("$sitepath/html/header.php"); print("No password Entered."); login_form(); print("<BR><BR> Lost Password?"); lostpass_form(); //include("$sitepath/html/footer.php"); exit; } elseif($_POST[username]=="") { //include("$sitepath/html/header.php"); print("No username Entered."); login_form(); print("<BR><BR> Lost Password?"); lostpass_form(); //include("$sitepath/html/footer.php"); exit; } elseif($numrows == "0") { //include("$sitepath/html/header.php"); print("Username and Password doesnt match!"); login_form(); print("<BR><BR> Lost Password?"); lostpass_form(); //include("$sitepath/html/footer.php"); exit; } else { setcookie("username","$_POST[username]",time()+30000000); setcookie("password","$md5_password",time()+30000000); echo "<meta http-equiv=refresh content=\"2;url=$siteurl/loggedin.php\">"; //include("$sitepath/html/header.php"); print("your now being logged in!"); //include("$sitepath/html/footer.php"); } } else { //include("$sitepath/html/header.php"); print("Your are already loggedin!"); //include("$sitepath/html/footer.php"); } } if($action=="") { //include("$sitepath/html/header.php"); login_form(); print("<BR><BR> Lost Password?"); lostpass_form(); //include("$sitepath/html/footer.php"); } ?>
  11. hmmm I would still be stuck with the different dates. The format of the database is far from practical all the date and time columns are in varchar but i have worked around that problem - unfortunately i cannot change them due to the data being exported systematically from an msaccess database. the existing database is structured like this: Title Time Date Location Spiderman 3 1/01/1900 10:30:00 AM 31/05/2007 Location 1 Spiderman 3 1/01/1900 10:30:00 AM 31/05/2007 Location 2 Spiderman 3 1/01/1900 11:30:00 AM 31/05/2007 Location 1 Spiderman 3 1/01/1900 11:30:00 AM 31/05/2007 Location 2 The formating of the dates and times from the varchar field i am fine with in fact i have AJAX working fine for selecting a movie by location and by date which will then show the session times. But what i am after shows all the dates and session times for a movie as formated in my previous post. Its the query/queries to achieve a result like this i am stuck on - given only the location and the movie name i want it to display the dates with times for any available dates in the database i.e MON, TUE, WED etc etc depending on dates that the movie will be screening.
  12. how about - <? $string='blah blah blha <img src="http://www.mysite.com/image.jpg" /> blah blah blah'; $imageurl=explode('src="http://',$string); $string=explode('"',$string); echo $string[1]; ?> There most likely is a much better way ?
  13. I generally use MYSQL and cookies -- You need a login form function - a database to store this info into and then the files which do all the work for you. Normally i have a functions file which will contain the Login form and if a user isnt logged in you display the login form - if a user is logged in then you display the content a logged in member would see. This can also be done with mutiple user levels see different content etc. The files you would need (named whatever you like): * Functions - contains a set of functions you can call like login form, forgotten password etc etc * Login - the script which processes the login - user checking - form completeness etc * loggedin - the login form is sent to here and sets cookies etc but only if the login form is valid *usercheck - can be included anywhere you want a check to be made where logged in content should be displayed. - If the user is logged in it will display relevant content if they arent it will say "Need to be logged in" in the area it is included. you would also need to create a registration form, maybe a validation form, and maybe a lost password form. It can become a bit of a headache. then you need if's buts and maybes
  14. Do you want to INSERT this or UPDATE ? Looks kinda like UPDATE not INSERT???
  15. <? $string='blah blah blha <img src="http://www.mysite.com/image.jpg" /> blah blah blah'; $imageurl=explode('"',$string); echo $imageurl[1]; ?>
×
×
  • 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.