![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
aebstract
-
Posts
1,105 -
Joined
-
Last visited
Posts posted by aebstract
-
-
$result = mysql_query("SELECT * FROM albums ORDER BY id ASC") or DIE(mysql_error()); while($r=mysql_fetch_array($result)) { $id=$r["id"]; $superid=$r["superid"]; $date_created=$r["date_created"]; $date_modified=$r["date_modified"]; $title=$r["title"]; $bg_color=$r["bg_color"]; echo "<li><a href=\"index.php?page=edit&edit=$superid\">edit</a> | <a href=\"index.php?page=album&album=$superid\">$title</a></li>"; $date_created_readable = date('m/d/Y', $date_created); echo "$date_created_readable"; }
and when I echo the date_created, it displays a unique timestamp for each result..
-
$date_created_readable = date('m/d/Y', $date_created);
echo "$date_created_readable";
That is what I have, but it is just displaying: 01/15/2008 for every value, but every row in the db has a different value for date_created.
-
I have a unix timestamp such as: 1200435437
I need to convert this in to something like m/d/Y with the date function, how can I go about doing this?
Thanks!
-
Well you're obviously gonna have to echo your results.. I was just showing you what you needed to do, the structure..
-
Basically run each row in your while loop where you are grabbing your information from the database.
<table> Grab database information while (blabla) { <tr><td></td></tr> } </table>
Very basic but its just so you know the idea you need. Start and end your table before the while and create your new rows each time the while loop is ran. If you want a header row you can put that up above the while also.
-
Can you explain what its doing, like why it works so I understand for future
I think the -1 is taking a character off before the @ sign
-
I'm trying to figure out how to remove the @ and everything after it in an email address. So test@tester.com would end up as just test.
I dunno if I'm in the right direction or not, possibly an easy way to do this and I'm going way out of the way..
str_replace (^[@]$,,$email);
-
Works just like what I was looking for, thank you
-
What do the % signs do? If my search was for say "RKK-940" would it be like %RKK-940% and find that exact matching in my part numbers? So it would find part SPRKK-940006 ?
-
I suck at regular expressions..
I know some of the commands and whatnot, and almost understand the syntax of it. I'm wanting to retrieve information from a database, basically a simple search engine. It will search one column for anything that includes what was searched for. Example being:
If you search for 20.
Let's say there are 3 parts with 20 in them,
BPRSW20
SWO20JAL
204589
I want to be able to retrieve the rows with these parts in them. Any row that has the searched for criteria, anywhere in the part number. I don't want anyone to write this for me but help me out with how I would go about doing it please.
-
Oh, well I tried to put the form opening tag outside of the table and didn't work, also tried to put the closing tag inside of the table and that didn't work. Thinking it isn't because of that overlay.
-
How is it "wrong"? I was unaware that there was an actual correct spot to start a form, which may easily be causing the problem.
-
Well looking at the code, could it be the way the dropdown is generated or something? What kind of problem causes this? Possible because of the table it is in?
-
<?php if(isset($_SESSION["id"])) { header("Location: /accounthome/"); exit(); } //Doesn't this happen in the include('connect.php') in index.php? mysql_connect("localhost","berryequipment","gU8Kso8Y") or die(mysql_error()); mysql_select_db("berryequipment_net_db"); if(isset($_POST['submit'])) { if(empty($_POST['password'])) { $error .= 'You must fill in a password <br />'; } if(!strlen($error)) { $result = mysql_query("SELECT * FROM `users` WHERE `plant` = '".mysql_real_escape_string($_POST['dropdown'])."' AND `password` = '".md5($_POST['password'])."'") or die("Query error: ".mysql_error()); if(mysql_num_rows($result) == 0) { $error .= "The pasword you entered did not match the plant location you chose."; } else { $worked = mysql_fetch_array($result); $_SESSION["id"] = $worked['plant']; header("Location: /accounthome/"); exit; } } } $content .= '<center><table><tr><td><form action="/login/" method="post">Location: </td><td><select name="dropdown">'; $result = mysql_query("SELECT * FROM `plants` ORDER BY `plantloc` ASC") or DIE(mysql_error()); while($r = mysql_fetch_array($result)) { $id = $r['id']; $plantloc = $r['plantloc']; $content .= "<option value=\"{$id}\">{$plantloc}</option>\n"; } $content .= '</select></td></tr><tr><td> Password: </td><td> <input type="password" name="password" size="6" /> </td></tr><tr><td></td><td> <input type="submit" name="submit" value="login" /> </td></tr></table></center></form>'; ?>
Okay, here is the problem I am having:
If you're on internet explorer and fill out your password and hit enter, it just reloads the page.. Firefox will submit the form and log you in. Is this a problem with the php, just the form or something else? I am not sure and it is a problem because a lot of people like to just push enter after inserting their passwords! Please help, and thank you.
-
Works great, thanks. I did check google btw, I searched many different topics and found a lot on mod rewrite (none of which seemed like it would even work correctly) but this helped a lot. Thanks.
-
What is the best way to force the url to an https prefix vs an http? I'm thinking mod rewrite but I can't figure out a way to do it correctly, what I currently use in my rewrite is:
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([[:alnum:]_]+)/$ /index.php?page=$1 [NC,L] RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2 [NC,L] RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3 [NC,L]
This is on an apache server, perhaps there is another way of doing this or someone knows an easy way to do it with rewrite?
-
// To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: Candace Painter <tcantwell@berryequipment.net>' . "\r\n"; $headers .= 'From: $name <$email>' . "\r\n"; if ($payment == billme) { // Mail it mail($to, $subject, $message, $headers);
Thanks
-
I'm trying to send out an html email, and it was working before and was unaware that it quit working until recently.
The code:
$emailbody = "<font style=verdana> <table width=732 cellpadding=3><tr bgcolor=#f3f3f3 cellspacing=6><td> <u>$plantloc</u></td><td>$name - $telephone</td><tr><td> $address2</td><td> <table><tr><td align=right> <b>PO #:</b> </td><td> $ponumber </td></tr><tr><td align=right> <b>Shipping:</b> </td><td> $shipping </td></tr><tr><td align=right> <b>Date:</b> </td><td> $datetime </td></tr></table> </td></tr></table> <br /> <u>Special Notes</u> <table width=732 cellpadding=3 bgcolor=f3f3f3> <tr><td>$notes</td></tr> </table> <br /> $parts<br /><br /> </font> "; $to = 'tcantwell@berryequipment.net' . ', '; // note the comma $_SESSION['to'] = "$to"; // subject $subject = 'Purchase Orders'; $_SESSION['subject'] = "$subject"; // message $message = " <html> <head> </head> <body> $emailbody </body> </html> "; $_SESSION['message'] = "$message"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: Candace Painter <tcantwell@berryequipment.net>' . "\r\n"; // Mail it if ($payment == billme) { mail($to, $subject, $message, "FROM:$email");
and how it displays in the email after being sent:
<html> <head> </head> <body> <font style=verdana> <table width=732 cellpadding=3><tr bgcolor=#f3f3f3 cellspacing=6><td> <u>Tyson Foods - Forest, MS</u></td><td>Test Number2 - 666-777-8888</td><tr><td> </td><td> <table><tr><td align=right> <b>PO #:</b> </td><td> 5647 </td></tr><tr><td align=right> <b>Shipping:</b> </td><td> Expedite </td></tr><tr><td align=right> <b>Date:</b> </td><td> 03/11/2008 - 8:13 AM </td></tr></table> </td></tr></table> <br /> <u>Special Notes</u> <table width=732 cellpadding=3 bgcolor=f3f3f3> <tr><td></td></tr> </table> <br /> <table width=660 cellpadding=3><tr bgcolor=#8d8d8d cellspacing=6><td width=10 align=center><b>LOC</b></td><td width=85><b>Part Number</b></td><td width=300><b>Description</b></td><td width=50 align=right><b>Price</b></td><td width=10 align=right><b>QTY</b></td></tr><tr cellspacing=6><td align=center bgcolor="#c0c0c0">1</td><td bgcolor="#c0c0c0" width="85">APH-FR-9908-L</td><td bgcolor="#c0c0c0" width="300">SAW MOUNTING FRAME - LEFT HAND</td><td bgcolor="#c0c0c0" width=50 align=right>491.17</td><td bgcolor="#c0c0c0" width=10 align=right>2</td></tr><tr cellspacing=6><td align=center bgcolor="#dddddd">1</td><td bgcolor="#dddddd" width="85">APH-FR-9908-R</td><td bgcolor="#dddddd" width="300">SAW MOUNTING FRAME - RIGHT HAND</td><td bgcolor="#dddddd" width=50 align=right>491.17</td><td bgcolor="#dddddd" width=10 align=right>2</td></tr><tr cellspacing=6><td align=center bgcolor="#c0c0c0">40</td><td bgcolor="#c0c0c0" width="85">BPE-MT-200-2</td><td bgcolor="#c0c0c0" width="300">HYDR! AULIC BRUSH MOTOR MOUNT</td><td bgcolor="#c0c0c0" width=50 align=right>148.21</td><td bgcolor="#c0c0c0" width=10 align=right>3</td></tr><tr cellspacing=6><td align=center></td><td></td><td align=right><B>TOTAL</B></td><td bgcolor=yellow align=right>2409.31</td><td></td></tr></table><tr cellspacing=6><td align=center></td><td></td><td><ul><li>Pricing does not include shipping charges</li></ul></td><td></td><td></td></tr></table><br /><br /> </font> </body> </html> No virus found in this incoming message. Checked by AVG. Version: 7.5.518 / Virus Database: 269.21.7/1323 - Release Date: 3/10/2008 11:07 AM
As if it was surrounded by "[ code ]" tags in the email. Of course without the little box and all, but same effect..
-
That worked like a charm, thanks!
-
It's all in the same table, isn't it? Shouldn't be too hard to get it working. Create a column in your table and call it "alliance" or whatever you want. When the commander makes his alliance and sets his alliance name "A1" it will be set in the database. Whenever someone joins his alliance, they will get the same set value for their alliance. If they leave, you can update it with a blank alliance or however you want. That's just the basic, what you're needing?
-
I'm using this code to completely clear all sessions and reset the session id back to what it was. This way whoever is logged in will remain logged in and all sessions that were set while they have been logged in, will be cleared. Is there a better way of doing this? It isn't keeping the user logged in like it is supposed to.
$sessionid = $_SESSION["id"]; unset ($_SESSION); session_destroy(); $_SESSION["id"] = $sessionid;
-
Okay I did a few tests and looked at what was being set as passwords to make sure everything was working right. It seems that if we have:
PLANT A
user 1 - pass1
user 2 - pass2
pass1 will work for user 2 and pass2 doesn't work at all. This is as far as what is displayed out as results. If I knew what it was encrypting to, then it wouldn't be a problem (so its no the login). Whenever there is more than one user for a plant, it does something odd with the displaying what it sets?
-
Well I mean, it is updating every row correctly, every password is getting changed in that table..
-
I got a script that resets every user's password in a db. In my db I have a plants table, and each plant has several users, which I have a users table for. Now everything seems to work. If I run my reset script, it creates a new pw for every user.. here is the weird part. I'm trying to log in to a plant that has two users, I can login as one but not the other. Returns a false password (no results returned from db). Now if I get the md5 of something random, like let's say "pencil" and insert it manually in to my db as the user that I couldn't log in as.. it then lets me with that new password. However, I can no longer log in as the first user that was working..?
reset:
<?php include "connect/todb.php"; function makePass () { $length = 6; $password = ""; $possible = "0123456789bcdfghjkmnpqrstvwxyz"; for($i = 0;$i < $length;$i++) $password .= substr($possible, mt_rand(0, strlen($possible)-1), 1); return $password; } $color1 = "#dddddd"; $color2 = "#c0c0c0"; $row_count = 0; echo "<table bgcolor=\"#000000\" cellpadding=\"5\" cellspacing=\"1\">"; $result = mysql_query("SELECT * FROM plants ORDER BY plantloc ASC") or DIE(mysql_error()); while($r=mysql_fetch_array($result)){ $id=$r["id"]; $plantloc=$r["plantloc"]; $results = mysql_query("SELECT * FROM users WHERE plant = '$id'") or DIE(mysql_error()); while($s=mysql_fetch_array($results)){ $user_id=$s["user_id"]; $plant=$s["plant"]; $email=$s["email"]; $password = makePass(); $password2 = md5($password); mysql_query("UPDATE users SET password='$password2' WHERE plant=$id LIMIT 1") or DIE(mysql_error()); $row_color = ($row_count % 2) ? $color1 : $color2; echo "<tr height=20><td bgcolor=\"$row_color\">$plantloc</td><td bgcolor=\"$row_color\">$password</td><td bgcolor=\"$row_color\">$email</td></tr>"; $row_count++; } } echo "</table>"; ?>
login:
<?php if(isset($_SESSION["id"])) { header("Location: /accounthome/"); exit(); } include "connect/todb.php"; if(isset($_POST['submit'])) { if(empty($_POST['password'])) { $error .= 'You must fill in a password <br />'; } if(!strlen($error)) { $result = mysql_query("SELECT * FROM `users` WHERE `plant` = '".mysql_real_escape_string($_POST['dropdown'])."' AND `password` = '".md5($_POST['password'])."'") or die("Query error: ".mysql_error()); if(mysql_num_rows($result) == 0) { $error .= "The pasword you entered did not match the plant location you chose."; } else { $worked = mysql_fetch_array($result); $_SESSION["id"] = $worked['plant']; header("Location: /accounthome/"); exit; } } } $content .= '<center><table><tr><td><form action="/login/" method="post">Location: </td><td><select name="dropdown">'; $result = mysql_query("SELECT * FROM `plants` ORDER BY `plantloc` ASC") or DIE(mysql_error()); while($r = mysql_fetch_array($result)) { $id = $r['id']; $plantloc = $r['plantloc']; $content .= "<option value=\"{$id}\">{$plantloc}</option>\n"; } $content .= '</select></td></tr><tr><td> Password: </td><td> <input type="password" name="password" size="6" /> </td></tr><tr><td></td><td> <input type="submit" name="submit" value="login" /> </td></tr></table></center></form>'; ?>
display date readable
in PHP Coding Help
Posted
It works, the difference in time is actually in seconds. Sorry for the confusion and thanks for the help.