PHP - More Coding With Date, Still Can't Figure It Out...
I have done a query from a table with a timestamp like so DATE(...)
I have this value as $defend_started (if I do an echo on this I get: 2011-04-30) Can I use this variable against other dates? Perhaps even "DATE_ADD($defend_started, INTERVAL 1 DAY)" ? If not, than what are the alternatives? Similar Tutorials// Nav Tabs $query = "select DISTINCT YEAR(sold_date) FROM Sold"; $result = mysql_query($query); $numrows = mysql_num_rows($result); while($row = mysql_fetch_array($result)){ $year = substr($row['sold_date'], 0, -6); $navTab .= '<a class="miniTabOn" href="index.php?date='.$year.'">'.$year.'</a>'; } I am trying to create a link for each year of items in my database, yet the text is not showing up... The "nav tab" is, because I can see the background image from the class="miniTabOn". Can anyone spot an error? Hey, I'm using a script which allows you to click on a calendar to select the date to submit to the database. The date is submitted like this: 2014-02-08 Is there a really simple way to prevent rows showing if the date is in the past? Something like this: if($currentdate < 2014-02-08 || $currentdate == 2014-02-08) { } Thanks very much, Jack Hello. I'm new to pHp and I would like to know how to get my $date_posted to read as March 12, 2012, instead of 2012-12-03. Here is the code: Code: [Select] <?php $sql = " SELECT id, title, date_posted, summary FROM blog_posts ORDER BY date_posted ASC LIMIT 10 "; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { $id = $row['id']; $title = $row['title']; $date_posted = $row['date_posted']; $summary = $row['summary']; echo "<h3>$title</h3>\n"; echo "<p>$date_posted</p>\n"; echo "<p>$summary</p>\n"; echo "<p><a href=\"post.php?id=$id\" title=\"Read More\">Read More...</a></p>\n"; } ?> I have tried the date() function but it always updates with the current time & date so I'm a little confused on how I get this to work. I have tried a large number of "solutions" to this but everytime I use them I see 0000-00-00 in my date field instead of the date even though I echoed and can see that the date looks correct. Here's where I'm at: I have a drop down for the month (1-12) and date fields (1-31) as well as a text input field for the year. Using the POST array, I have combined them into the xxxx-xx-xx format that I am using in my field as a date field in mysql. <code> $date_value =$_POST['year'].'-'.$_POST['month'].'-'.$_POST['day']; echo $date_value; </code> This outputs 2012-5-7 in my test echo but 0000-00-00 in the database. I have tried unsuccessfully to use in a numberof suggested versions of: strtotime() mktime Any help would be extremely appreciated. I am aware that I need to validate this data and insure that it is a valid date. That I'm okay with. I would like some help on getting it into the database. Alright, I have a Datetime field in my database which I'm trying to store information in. Here is my code to get my Datetime, however it's returning to me the wrong date. It's returning: 1969-12-31 19:00:00 $mysqldate = date( 'Y-m-d H:i:s', $phpdate ); $phpdate = strtotime( $mysqldate ); echo $mysqldate; Is there something wrong with it? 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 i was wondering how i would go about making a single page that would have sections on it and if you click a section the page reloads and shows the information that is within that section? i got my code to show both the section and its information at the same time but cannot figure out how to do the above. please help. thank you -Adam Hi, good pm masters! So i have this code Code: [Select] <td><img src="images/layout/<?php echo base64_decode($_GET['layout']); ?>" width="50%" height="50%" /></td> $_GET['layout'] is encoded that's y i have a decode there, the image name will then be combined to the src like this -> image/layout/1.jpg.. when i view the source the src is correct but it doest show the image.. cant seem to find whats wrong.. my folder structure is sandbox>images>layout>file.jpg the php file (where the code above is) inside the sandbox. sorry if am i missing something sooo eaasy.. i was doin alot of coding this morning until now so i don't know what to think anymore.. The page that I'm working on is a quiz results page. In this section of code I am simply printing the question, then each answer choice is printed depending on a few if statements. Let's say the answer choice in this first statement was "Baseball." The four possibilities depending on the student answer I want a Baseball - You Got This Right or Baseball - Correct Answer or Baseball - Your Answer or Baseball So if the student gets a question wrong one choice should say "Correct Answer" next to it and one other would have "Your Answer" next to it. Pretty simple and straightforward. I can get the correct results from everything but the second ifelse statement (Baseball - Your Answer). No matter what i do I can't get this to work. Here is the code below and some clarifications: $StudAns = Student's answer $Choices = The particular answer choice being evaluated $CorrectAnswer = obvious Code: [Select] $StudAns = array($QChoices['Q1Choice'], $QChoices['Q2Choice'], $QChoices['Q3Choice']); $ContentsQuery = mysql_query("SELECT Question, Choice1, Choice2, Choice3, Correct_Answer FROM Module_1_Quiz") or die(mysql_error()); while ($Contents = mysql_fetch_array($ContentsQuery)) { $i =0; $Choices = array($Contents['Choice1'], $Contents['Choice2'], $Contents['Choice3']); $CorrectAnswer = $Contents['Correct_Answer']; echo "<span id='answers'><table width = '600' border='0' align='center' id='answers' bgcolor='#FFFFCC'><tr><td>"; echo $Contents['Question']; echo "</td></tr>"; echo "<tr><td><ol type = 'a'><li>"; // Checks what should be printed for the first answer option if ($Choices[$i] == $CorrectAnswer && $StudAns[$i] == $CorrectAnswer) { echo $Choices[$i]; echo " - You Got This Right!"; } elseif ($Choices[$i] == $CorrectAnswer && $StudAns[$i] != $CorrectAnswer) { echo $Choices[$i]; echo " - Correct Answer"; } elseif ($StudAns[$i] != $CorrectAnswer && $CorrectAnswer[$i] != $Choices[$i]) { echo $Choices[$i]; echo " - Your answer"; } else { echo $Choices[$i]; } echo "</li><li>"; $i++; // Checks what should be printed for the second answer option if ($Choices[$i] == $CorrectAnswer && $StudAns[$i] == $CorrectAnswer) { echo $Choices[$i]; echo " - You Got This Right!"; } elseif ($Choices[$i] == $CorrectAnswer && $StudAns[$i] != $CorrectAnswer) { echo $Choices[$i]; echo " - Correct Answer"; } elseif ($StudAns[$i] != $CorrectAnswer && $CorrectAnswer[$i] != $Choices[$i]) { echo $Choices[$i]; echo " - Your answer"; } else { echo $Choices[$i]; } echo "</li><li>"; $i++; // Checks what should be printed for the third answer option if ($Choices[$i] == $CorrectAnswer && $StudAns[$i] == $CorrectAnswer) { echo $Choices[$i]; echo " - You Got This Right!"; } elseif ($Choices[$i] == $CorrectAnswer && $StudAns[$i] != $CorrectAnswer) { echo $Choices[$i]; echo " - Correct Answer"; } elseif ($StudAns[$i] != $CorrectAnswer && $CorrectAnswer[$i] != $Choices[$i]) { echo $Choices[$i]; echo " - Your answer"; } else { echo $Choices[$i]; } echo "</li></ol></table></span>"; } Thanks everyone! I'm terrible at designing websites (that's pretty much out of the question), but I would like to work on my php skills. I just can't figure out anything I can write that isn't extremely hard.. ideas? guys is it possible to somehow compare something like these two together and make a choice depending on the out come SystemKeyv1.0 and PasswordCrackerv2.0 PasswordCrackerv2.0 is grater than SystemKeyv1.0 can these be compared somehow? thank for advise guys; Cheers hey all; i created a script that just allows a user to record an IP address and it presents them in a table.. issue: each record draws its own row and a colum for an image (for deleting).. I can't igure out how I can delete the one row when they click on image(little x) to delete... issue2: it's showing the error message when you bring up the screen telling them they didn't enter anything even prior to them hitting submit... issue3: it's allowing me to enter the same IP again code: <?php session_start(); if (!isset($_SESSION['username'])) { echo "Sorry you must be logged in to view this page<BR>"; echo "Please <a href='index.php'>GO BACK</a> and try again"; exit(); } else { if ($_SESSION['username']) { $username = $_SESSION['username']; $userid = $_SESSION['userid']; } } //script v1.0 ipdatabase.php - create a list of IP addresses that the user has added to their list to remember. can add or remove IPs ?> <style type="text/css"> <!-- .style1 {color: #FFFFFF} --> </style> <table align="center" width="550" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000"> <!--DWLayoutTable--> <tr> <td height="106" colspan="3" valign="top"><img src="images/myvpc.png" width="550" height="106"></td> </tr> <tr> <td width="16" height="57"> </td> <td width="516" valign="top"><div align="center" class="style1"> <p>IP DATABASE</p> <p align="left">add or remove IP address you have encountered in the game thus far for later use!</p> </div></td> <td width="18"> </td> </tr> <tr> <td height="100"> </td> <td valign="top"> <form action="ipaddressadd.php" method="POST"> <p> </p> <p><span class="style1">IP ADDRESS</span>: <input type="text" name="ipaddress" size="16"> <input type="submit" name="submit" value="submit"> </p> </form></td> <td> </td> </tr> <tr> <td height="17"></td> <td valign="top"><img src="images/filler.jpg" width="516" height="19"></td> <td></td> </tr> <tr> <td height="296"></td> <td valign="top"> <?php $submit = $_POST['submit']; if ($submit) { $ipaddress = ip2long($_POST['ipaddress']); } //script to add IP to database include('connectdb.php'); mysql_select_db('heaven_users') or die (mysql_error()); if (isset($ipaddress,$submit)) { mysql_query("INSERT INTO ipdatabase (userid,ipaddress) VALUE ('$userid','$ipaddress')") or die ("Could Not write to database, Please try again"); } else echo "<center><font color='#ff0000'>You didn't add anything mate!</font></center>"; echo "<br />"; echo "<table align='center' border='1'><tr align='center'><th><font color='#ffffff'>SAVED IPADDRESS</font></th></tr><tr>"; $query = mysql_query("SELECT * FROM ipdatabase WHERE userid = '$userid'"); while ($result = mysql_fetch_assoc($query)) { $ip = long2ip($result['ipaddress']); echo "<tr align=\"center\"><td><font color='#ffffff'>".$ip."</font></td><td><a href='deleteip.php'><img border='0' src='images/delete.png'></a></td></tr>"; } echo "</table>"; ?> </td> <td></td> </tr> </table> Okay, the function appears to work just fine, except it doesn't add to the database. I don't have any errors, so I'm not quite sure what is going on. I've got an echo on the $id and $item_id, and both were pulling correctly. Just not being added to the table `sale`... Anyone help? Thanks in advance! function addshopinv($id) { error_reporting(E_ALL); ini_set('display_errors', 1); if (isset($_POST["submit"])) { extract($_POST); $errors = 0; $errorlist = ""; if ($name == "") { $errors++; $errorlist .= "Name is required.<br />"; } else if ($errors == 0) { $dbh=dbconnect() or die ("Userlist read error: " . mysql_error()."<br>"); mysql_select_db("XXX"); $query = mysql_query("SELECT id FROM items WHERE name='$name'"); while ($result = mysql_fetch_array($query)){ $item_id = $result['id']; echo $id; $query1 = mysql_query("INSERT INTO sale SET shop_id='$id', item_id='$item_id"); } admindisplay("Inventory Item Added.","Add New Inventory Item"); } else { admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Add New Item to Shop"); } } i have an array called $imageArray like this Array ( [0] => 'Dashka'_Darren_Sheehan_1.jpg [1] => 'Dashka'_Darren_Sheehan_10.jpg [2] => 'Dashka'_Darren_Sheehan_2.jpg [3] => 'Dashka'_Darren_Sheehan_3.jpg [4] => 'Dashka'_Darren_Sheehan_4.jpg [5] => 'Dashka'_Darren_Sheehan_5.jpg [6] => 'Dashka'_Darren_Sheehan_6.jpg [7] => 'Dashka'_Darren_Sheehan_7.jpg [8] => 'Dashka'_Darren_Sheehan_8.jpg [9] => 'Dashka'_Darren_Sheehan_9.jpg [10] => . [11] => .. [12] => Aaron_Kidney_1.jpg [13] => Aaron_Kidney_10.jpg [14] => Aaron_Kidney_11.jpg [15] => Aaron_Kidney_12.jpg [16] => Aaron_Kidney_13.jpg [17] => Aaron_Kidney_14.jpg [18] => Aaron_Kidney_15.jpg [19] => Aaron_Kidney_16.jpg [20] => Aaron_Kidney_17.jpg [21] => Aaron_Kidney_18.jpg and i also have another array called $_names Array ( [0] => 'Dashka'_Darren_Sheehan [1] => Beefit_Gyms [2] => Aaron_Kidney [3] => Dean_Mitchell [4] => Colin_O_Neill [5] => Keith_McManus ) if a name in array $_names exists in the $imageArray i want to insert the images for that person into one column of a table like this <tr> <?php foreach ($names as $name): ?><th><?php htmlout($name); ?></th><?php endforeach; ?> </tr> <tr> <td><img src="../images/'Dashka'_Darren_Sheehan_1.jpg" width="204"/></td> <td><img src="../images/Aaron_Kidney_1.jpg" width="204"/></td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td><img src="../images/'Dashka'_Darren_Sheehan_2.jpg" width="204"/></td> <td><img src="../images/Aaron_Kidney_2.jpg" width="204"/></td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> can anyone help me write the logic for this?? I cant figure it out... Hi im still learning php and have been running through the tutorials on making a user authentication system but im getting an error on one line but ive got the same code else where and its fine... Code: [Select] // Must have at least one character if (strspn($_POST['user_name'],$span_str) == 0) { return false; } Im getting the error on the if statment but no matter what i try it still tells me theres an error... Heres the full function code: Code: [Select] function account_namevalid() { // parameter for use with strspan $span_str = "abcdefghijklmnopqrstuvwxyz" . "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"; // Must have at least one character if (strspn($_POST['user_name'],$span_str) == 0) { return false; } // Must contain all legal characters if (strspn($_POST['user_name'],$span_str) != srnlen($name)) { return false; } // Min and Max length if ($strlen($_POST['user_name']) < 5) { return false; } if strlen($_POST['user_name']) > 25 { return false; } // Illegal names if (eregi("^((root)|(bin)|(deamon)|(adm)|(lp)|(sync)|(shutdown)|(halt)|(mail)|(news)|(uucp)|(operator)|(games)|(mysql)| (httpd)|(nobody)|(dummy)|(www)|(cvs)|(shell)|(ftp)|(irc)|(debian)|(ns)|(download)))$", $_POST['user_name'])) { return false; } if (eregi("^(anoncvs_)", $_POST['user_name'])) { return false; } return true; } Any help or info would be greatfull... Cheers Chris I am trying to redirect users depending on their coupon code input I am using the following script in the form created in dreamweaver: Code: [Select] <form action="CodeUserredirect.php" method="post" enctype="multipart/form-data" name="" id=""> <input type="hidden" name="redirect" value="CodeUserredirect.php" /> <p class="style4">Redeem your Gift Certificate Savings for Special Orders he </p> <p><span class="style78">Enter Coupon code</span> <input name="CouponCode" type="text" id="CouponCode" size="9"> <input type="submit" name="CheckCode" id="CheckCode" value="Check Code"> <br/> <br/> </p> </form> and I am using the following code in my php file: <?php$coupon_code = $_POST['couponcodenumber'];if ($coupon_code = $some_other_value) { $redirected_address = 'Location: specialordersDiscountForm.php'; header ($redirected_address); exit();} else { $redirected_address = 'Location: specialorderwrongcode.php'; header ($redirected_address); exit();}?> () Not sure where the issue is in these coding but it is not working to redirect users depending on their coupon input as intended. Can anyone supply me with a working code or explain what the issue is? thanks! hello, newbie here. i am struggling with the way my table is displayed. as you can see if you goto http://durhamit.ca/citycore/2/tsreview.php and goto october 20th, Rui Zhang has 3 entries and im trying to make it display one at a time. here is my code if anyone can point me in the right direction. Code: [Select] <?php include 'config.php'; include 'javascript.php'; $d = date("d"); $m = date("m"); $y = date("Y"); ?> <center> <form method="POST"> Month: <select size="1" name="m"> <option selected="selected" value="<?php echo $m; ?>"><?php echo $m; ?></option> <?php $mlist = range( 1,12 ); foreach ($mlist as $v ) { echo "<option value=\"$v\">$v</option>\n"; } ?> </select> Day: <select size="1" name="d"> <option selected="selected" value="<?php echo $d; ?>"><?php echo $d; ?></option> <?php $dlist = range( 1,31 ); foreach( $dlist as $v ) { echo "<option value=\"$v\">$v</option>\n"; } ?> </select> Year: <select size="1" name="y"> <option selected="selected" value="<?php echo $y; ?>"><?php echo $y; ?></option> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> </select> <input type="submit" value="View" name="view"> </form> <?php if(isset($_POST['view'])) { $y3=$_POST['y']; $m3=$_POST['m']; $d3=$_POST['d']; $pdate=$y3."-".$m3. "-".$d3; $pdate1 = date( 'D M j', strtotime($pdate) ); } else { $pdate = date('Y-m-d', strtotime("-1 day") ); $pdate1 = date( 'D M j', strtotime($pdate) ); } $pdate2 = date('Y-m-d', strtotime("-1 day, $pdate") ); $y4 = date('Y', strtotime("$pdate2") ); $m4 = date('m', strtotime("$pdate2") ); $d4 = date('d', strtotime("$pdate2") ); $pdate3 = date('Y-m-d', strtotime("+1 day, $pdate") ); $y5 = date('Y', strtotime("$pdate3") ); $m5 = date('m', strtotime("$pdate3") ); $d5 = date('d', strtotime("$pdate3") ); echo "<table border='1' style='border-collapse: collapse' bordercolorlight='#000000' bordercolordark='#000000' width='98%' align='center'>"; echo "<tr>"; echo "<td width='100%' colspan='9' align='center'>"; ?> <table border='0' cellpadding='0' width='100%'> <tr> <td width='10%' align="center"> <form name="back" method="POST"> <input type="submit" value="<<<" name="view"> <input type="hidden" name="y" value="<?php echo "$y4"; ?>"> <input type="hidden" name="m" value="<?php echo "$m4"; ?>"> <input type="hidden" name="d" value="<?php echo "$d4"; ?>"> </form> </td> <td align="center"><b>Timesheets For <?php echo "$pdate1"; ?></b></td> <td width='10%' align="center"> <form name="forward" method="POST"> <input type="hidden" name="y" value="<?php echo "$y5"; ?>"> <input type="hidden" name="m" value="<?php echo "$m5"; ?>"> <input type="hidden" name="d" value="<?php echo "$d5"; ?>"> <input type="submit" value=">>>" name="view"> </form> </td> </tr> </table> <?php echo "</td>"; echo "</tr>"; $result5 = mysql_query("SELECT * FROM staff ORDER BY name"); while($row = mysql_fetch_array($result5)) { $eid=$row['eid']; $mname=$row['name']; $result3 = mysql_query("SELECT * FROM timesheet WHERE date = '$pdate' AND eid = '$eid'"); $talltime = 0; while($row3 = mysql_fetch_array($result3)) { $tid=$row3['id']; $tdate=$row3['date']; $tjobnumber=$row3['jobnumber']; $teid=$row3['eid']; $tdescription=$row3['description']; $tsignin=$row3['start']; $tfinish=$row3['finish']; $tlunch=$row3['lunch']; $tkms=$row3['kms']; $tschednum=$row3['schednum']; $tapproval=$row3['approval']; if("$tapproval" == "1") { $tapproval1="<font color='#00FF00'>In Progress</font>"; } if("$tapproval" == "2") { $tapproval1="<a target='_blank' href='approve.php?id=$tid'><font color='#FF0000'>Approve</font></a><br /> <a href='edittimesheet.php?id=" . $tschednum . "'>Edit</a>"; } if("$tapproval" == "3") { $tapproval1="Approved"; } $tdate1 = date( 'M j, Y', strtotime($tdate) ); $tsignin1 = date( 'g:i a', strtotime($tsignin) ); $tfinish1 = date( 'g:i a', strtotime($tfinish) ); if( empty($tfinish) ) { $tfinish2="<i>In Progress"; } else { $tfinish2="$tfinish1"; } $shortid=substr($tjobnumber, 5, -1); //remove the first 5 characters and minus the last character $result = mysql_query("SELECT * FROM jobs WHERE id = '$shortid'"); while($row = mysql_fetch_array($result)) { $jstatus=$row['status']; } $result4 = mysql_query("SELECT * FROM schedule WHERE id = '$tschednum'"); while($row4 = mysql_fetch_array($result4)) { $sid=$row4['id']; $sdate=$row4['date']; $seid=$row4['eid']; $sjobnumber=$row4['jobnumber']; $sstarttime=$row4['starttime']; $sstatus=$row4['status']; $setime=$row4['etime']; } $log_in_time_string = strtotime($tsignin); $log_out_time_string = strtotime($tfinish); $difference_in_seconds = ($log_out_time_string - $log_in_time_string); $tbilled = ($difference_in_seconds / 3600); if($tbilled < 0) { $tbilled1 = $tbilled + 24; } else { $tbilled1=$tbilled; } $tbilled2 = number_format(round($tbilled1*4)/4,2); $tbilled3 = $tbilled2 - $tlunch ; $talltime += $tbilled3; if ($talltime == '0' ) { echo "nothing"; } else { echo "<tr>"; echo "<td align='left' colspan='10'><b> " . $mname . "</b></td>"; echo "</tr>"; echo "<tr> <th align='center'>Date</th> <th align='center'>Job Number</th> <th align='center' width='30%'>Service Report</th> <th align='center'>Sign In Time</th> <th align='center'>Sign Out Time</th> <th align='center'>Lunch</th> <th align='center'>Time Billed</th> <th align='center'>Estimated</th> <th align='center'>Status</th> </tr>"; echo "<tr>"; echo "<td align='center'>" . $tdate1 . "</td>"; echo "<td align='center'>" . $tjobnumber . "</td>"; echo "<td align='center'>" . $tdescription . "</td>"; echo "<td align='center'>" . $tsignin1 . "</td>"; echo "<td align='center'>" . $tfinish2 . "</td>"; echo "<td align='center'>" . $tlunch . " hour</td>"; echo "<td align='center'>"; if ($tbilled3 > $setime ) { echo "<font color='red'><b>*** " . $tbilled3 . " hours ***</b></font>"; } else { echo "" . $tbilled3 . " hours"; } echo "</td>"; echo "<td align='center'>" . $setime . " hours</td>"; echo "<td align='center' nowrap>" . $tapproval1 . "</td>"; echo "</tr>"; } echo "<tr>"; echo "<td colspan='6' align='right'><b>Totals :</td>"; echo "<td align='center' colspan='3'>"; if ($talltime > "8" ) { echo "<font color='red'><b>*** " . $talltime . " hours ***</b></font>"; } elseif ($talltime < "0" ) { echo "<font color='red'><b>Still signed into a job</b></font>"; } else { echo "" . $talltime . " hours"; } echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='center' colspan='10' bgcolor='#D9FFD9'> </td>"; echo "</tr>"; } } echo "</table>"; include 'close.php'; ?> hello all, i can't get this to work; i'm able to echo both accts entered into the form via the _get but can't pull both balances using the $from_acct and $to_acct only the first query working do I have it formated wrong <?php //check for submit $submit = $_GET['submit']; //end looking for submit //set varibles if submit is present if (!$submit) { echo "Sorry Mate I don't see you have submitted anything for me to process"; } else { //make the connecting and set some varibles from _get $from_acct = $_GET['from_acct']; $to_acct = $_GET['to_acct']; $amount = $_GET['amount']; $connect = mysql_connect("localhost","root","") or die (mysql_error()); mysql_select_db('users') or die ("no such database exisit"); $query = mysql_query("SELECT * from members WHERE bankaccount=$from_acct") or die ("Could not locate to account"); $query2 = mysql_query("SELECT * from members WHERE bankaccount=$to_acct") or die ("Could not locate to account"); while ($result = mysql_fetch_assoc($query) && $result2 = mysql_fetch_assoc($query2)) { $fromb = $result['balance']; $tob = $result2['balance']; } //make a check to see if the account that is sending has the money to send if ($fromb<$amount) { echo "Mate you don't have enough cash to transfer " .$amount. "to this account<br />"; echo "Your Current Balance available for transfer is " .$fromb; } else { $newbalancefrom = $fromb - $amount; $newbalanceto = $tob + $amount; //make the transfer $transfer = mysql_query("UPDATE 'users' . 'members' SET 'balance' = '$newblanceto' WHERE bankaccount='$to_acct'") or die ("could not write to profile"); $transfer2 = mysql_query("UPDATE 'users' . 'members' SET 'balance' = '$newblancefrom' WHERE bankaccount='$from_acct'") or die ("Could Not Write to From Account"); if ($transfer) { echo "Transfer Complete Thanks!"; } else { echo "There was a error in the transfer process please try again"; } } } echo $fromb . "<br />"; echo $tob . "<br />"; echo $from_acct . "<br />"; echo $to_acct . "<br />"; ?> <h2>Peer to Peer Transfer</h2><br><br> <form action="testtrans.php" method="get"> Amount to Transfer: <input type="text" size="8" name="amount"><br> From Account: <input type="text" size="15" name="from_acct"> To Account: <input type="text" size="15" name="to_acct" /><br /> <input type="submit" name="submit" value="transfer" /> </form> Ok, so there are two functions, one encrypts data, the other one must decrypt. But I do not know how to implement it to decrypt. I need to know how to use the second function (number_decrypt). I need it so I enter the encrypted string into a text field and it outputs the decypted string. I dont need the html, I just dont understand how to implement it. Can someone look at this for me and possibly tell me how I could achieve this? Heres the code: function number_encrypt($plain) { mt_srand ((double) microtime() * 1000000); $password = ''; for ($i=0; $i<10; $i++) { $password .= rand(1,1000); } $salt = substr(md5($password), 0, 2); $password = md5($salt . $plain) . ':' . $salt; return $password; } function number_decrypt($encrypted,$plain) { $stack = explode(':', $encrypted); if (sizeof($stack) != 2) return false; if (md5($stack[1] . $plain) == $stack[0]) { return true; } return false; } Thanks! |