PHP - Moved: Will Pay To Have This Coded Today! Help!
This topic has been moved to PHP Freelancing.
http://www.phpfreaks.com/forums/index.php?topic=333553.0 Similar TutorialsHi all, I have created a successful registration and login page for what will eventually be a squash league website. I am struggling with the following issue. When a player logs in using their email address and password I want to populate some drop down boxes which are relevant to the person who has just logged in. These drop downs should show all the leagues the logged in user belongs to and the other drop down should show all the players the currently logged in player has ever played against so that they could view a head to head. So my code works but currently I have the id of the player who has logged in hard coded in my sql statements. I'm wondering if anyone can help me so that I can pass in the id of the player who is logged in as obviously the whole site is not going to work with hard coded values. The code is as follows: Code: [Select] <?php include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/magicquotes.inc.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc.php'; if (!userIsLoggedIn()) { include 'login.html.php'; exit(); } if (!userHasRole('Squash Administrator')) { $error = 'This page is only for Squash Administrators.'; include 'accessdenied.html.php'; exit(); } if(isset($_REQUEST['email'])) { include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php'; $email = mysqli_real_escape_string($link, $_REQUEST['email']); $sql = "SELECT id, firstname, lastname, email FROM player WHERE email = '$email'"; $result = mysqli_query($link, $sql); if(!$result) { $error = 'Unable to select players firstname from the database.' . mysqli_error($link); include 'error.html.php'; exit(); } while($row = mysqli_fetch_array($result)) { $players[] = array('id' => $row['id'], 'firstname' => $row['firstname'], 'lastname' => $row['lastname'], 'email' => $row['email']); } // //POPULATE THE OPPONENTS DROP DOWN BOX TO SHOW ALL PREVIOUS OPPONENTS // $sqlid = "SELECT id FROM player WHERE email = '$email'"; $playerid = mysqli_query($link, $sqlid); $sql = "SELECT DISTINCT player.firstname, game.player2_id AS opponent_id FROM player INNER JOIN game ON player.id = game.player2_id WHERE player1_id = '$row['id']' UNION SELECT DISTINCT player.firstname, game.player1_id AS opponent_id FROM player INNER JOIN game ON player.id = game.player1_id WHERE player2_id = '$row['id']'"; $result = mysqli_query($link, $sql); if(!$result) { $error = 'Unable to populate the players dropdown from the database.' . mysqli_error($link); include 'error.html.php'; exit(); } while($row = mysqli_fetch_array($result)) { $opponents[] = array('id' => $row['opponent_id'], 'firstname' => $row['firstname']); } include 'squash.html.php'; } ?> Thanks for your help and time in advance. I've coded an error variable thing to help with my login but it doesn't work and I am puzzled to why it does not. (>.<) error codes such as: Code: [Select] <?php /* checks to see if forms are filled in, if not, create a variable that will be used later. if forms are filled in than the variable is nothing and nothing will be echoed therefore passing onto the next if statement and repeating. */ if(!$_POST['username'] | !$_POST['pass']) { $errormessage_didnotfillinform = ('<center>You did not fill in a required field!</center>'); } else{ $errormessage_didnotfillinform = (''); } ?> Code: [Select] <html> <body> <!-- html such as the follow, goes here. --> <div align="center"><b>Log in</b> <form action="" method="post"> <table class="centered" border="0"> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr></table> </form></div> </body> </html> Code: [Select] <?php echo ( $errormessage_didnotfillinform ); if ( $errormessage_didnotfillinform ) == ('') { echo ( $errormessage_accountdoesnotexist ); } if ( $errormessage_accountdoesnotexist ) == ('') { echo ( $errormessage_invalidusernameorpassword ); } ?> I want to move a module, as shown in the attached jpeg. I want to move it to the position illustrated by the arrow, and I want to increase it's height so it fills the space but leaving a border. There is no module in the position that I can use, so I have to adjust the html coding (I presume). Can anyone help me with this? I have searched for help and I don't even know which file I need to change - whether it is the css or the html. Cheers, James. Hi I am trying to add a field to a database that is 4 days from the date the record is added, but it is not adding a value Code: [Select] $end_date=strtotime("+ 4 days"); $add_vehicle_sql=mysql_query("INSERT INTO `tbl_auction_lot`(`cust_id`,`reserve`,`make`,`model`,`spec`,`fuel`,`doors`,`mot_date`,`fns`,`fos`,`rns`,`ros`,`condition`,`reg_no`,`service_history`,`sale_type`,`status`,`keepers`,`gearbox`,`emissions`,`colour`,`date_first_reg`,`date_manufacture`,`bhp`,`engine_size`,`end_date`) VALUES ('$seller_id','$reserve','$make','$model','$body_style','$fuel_type','$no_of_doors','$mot','$fns','$fos','$rns','$ros','$vehicle_condition','$vrm','$service_history','auction','$status','$prev_keepers','$gearbox','$emissions','$colour','$date_reg','$date_man','$bhp','$engine_size','$end_date')") or die(mysql_error()); What am I doing wrong and what is there a better way to achieve the desired result. Hello, In my Mysql database, it has a datetime field. and I have created a $today = date('Y-m-d H:i:s'); <- today's date and time How do I write a query to run in PHP in order to get all today's items by comparing datetime field and $today? Thanks! I'm looking for a simple little code to display today's date, month, day, year and countdown to 365 days. Can anyone please help. Is there a way of getting today's date (in European format - day-month-year) into the body of an email sent via phpmailer? Many thanks. Hello, i'm trying to get the number of users that registered today and the number of users that registered yersterday (seperate), i've got this field in mysql: 'registertime' which stores data in this format 2011-11-14 14:53:49 also i have the field 'time' in the same format that updates everytime the user logs in. Now previously i wanted to find out users online in last 24 hours, the code i used for that is this: Code: [Select] $query = "SELECT COUNT(*) as Anzahl FROM customers WHERE country = 'de' AND time BETWEEN DATE_SUB( NOW(), INTERVAL 24 HOUR ) and NOW() "; $queryerg = mysql_query($query) OR die(mysql_error()); while($row = mysql_fetch_array($queryerg)){ $customers_on_de_24 = $row[0]; } How could i edit that to select the count just by date and ignore the time (hours minutes seconds) ? is it possible to do something like Code: [Select] $today = date("Y-m-d"); $result = mysql_query("SELECT * FROM staff where date = '.$today.' "); also, is it normal for the first entry in the database not to be displayed? i have 6 entries in a table and only 2-6 are shown. when i changed the id for 1 to 7, it only displayed 3-7. Hi All, Newbie here.
I run a website using xmb forums software as a base login script to connect to my database and created my own crude and simple pages for adding and displaying the data learning as I went. Over the years with recent upgrades of php versions its now virtually useless and unsecure code. I archive a lot of news articles but have had trouble pasting text that includes apostrophe's and special characters, but managed to fix that using addslashes() now. Can someone suggest a tutorial or a way to rebuild my site from scratch or something I can use as a template to connect to my pages ?. still shows all records in the database... any idea how i go about this? Code: [Select] $date= date('y-m-d'); $query=mysql_query("SELECT * FROM listing WHERE date >= $date") or die (mysql_error()); As far as I can see, this code: Code: [Select] $this->_licence_expires = date('Y/m/d', mktime(0, 0, 0, date("m"), date("d")-1, date("Y"))); results in accounts expiring 1 year from today, right? How can I change it so that it will result in expiry 9 months from today? TIA I have to two variables $cronlast and $cronnow in my php code. I need to have the time 7am of previous day in $cronlast variable and 7am today in $cronnow variable. I need the time in UNIX timestamp format. So everyday when I print the variable I should have: $cronlast=7am Yesterday(in Unix Timestamp) $cronnow=7am Today(in Unix Timestamp) I would appreciate any help. Hi, I have a table that contains posts and each post has a datetime field. Im trying to work out how I can show entries from today, this week and this month so I can have a link that shows all posts from today or this month etc. Any one know how I can do this ? My current piece of code that pulls the data from the db looks like this : Code: [Select] $texts= mysql_query("SELECT * FROM submittedtexts Order by id DESC LIMIT " . (($page - 1) * 6) . ", 6"); I want to add a bit that acts like : WHERE date = today Hope that makes sense, Im a bit of a newbie Thanks in advance, Scott Hi, I have a job listing website which displays the closing date of applications using: $expired_date (This displays a date such as 31st December 2019) I am trying to show a countdown/number of days left until the closing date. I have put this together, but I can't get it to show the number of days. <?php $expired_date = get_post_meta( $post->ID, '_job_expires', true ); $hide_expiration = get_post_meta( $post->ID, '_hide_expiration', true ); if(empty($hide_expiration )) { if(!empty($expired_date)) { ?> <span><?php echo date_i18n( get_option( 'date_format' ), strtotime( get_post_meta( $post->ID, '_job_expires', true ) ) ) ?></span> <?php $datetime1 = new DateTime($expired_date); $datetime2 = date('d'); $interval = $datetime1->diff($datetime2); echo $interval->d; ?> <?php } } ?> Can anyone help me with what I have wrong? Many thanks (continuing from topic title) So if I set a date of July 7 2011 into my script, hard coded in, I would like the current date to be checked against the hard coded date, and return true if the current date is within a week leading up to the hard coded date. How could I go about doing this easily? I've been researching dates in php but I can't seem to work out the best way to achieve what I'm after. Cheers Denno Hi guys, I'm putting together a small event system where I want the user to add his own date and time into a textfield (I'll probably make this a series of drop-downs/a date picker later). This is then stored as a timestamp - "0000-00-00 00:00:00" which displays fine until I try to echo it out as a UK date in this format - jS F Y, which just gives today's date but not the inputted date. Here's the code I have right now: Code: [Select] $result = mysql_query("SELECT * FROM stuff.events ORDER BY eventdate ASC"); echo "<br />"; echo mysql_result($result, $i, 'eventvenue'); echo ", "; $dt = new DateTime($eventdate); echo $dt->format("jS F Y"); In my mysql table eventdate is set up as follows: field - eventdate type - timestamp length/values - blank default - current_timestamp collation - blank attributes - on update CURRENT_TIMESTAMP null - blank auto_increment - blank Any help as to why this could be happening would be much appreciated, thanks. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=315910.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=309960.0 |