Jump to content

joshuaer

Members
  • Posts

    48
  • Joined

  • Last visited

Everything posted by joshuaer

  1. Thanks for the help birbal I am having a different problem with it now, when I run the script it is updating the password field now but I am getting this error Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1 And when i try to login with the new password it is not working <?php//ini_set('display_errors', 1);//error_reporting(E_ALL); include("../sql.php"); $email = $_POST['email'];$password = $_POST['password'];$sql = mysql_query("UPDATE `users` SET password = MD5(password) WHERE email ='$email'!= ''");mysql_query($sql) or die ("Error: ".mysql_error());echo "Database updated. <a href='update_email.php'>Return to edit info</a>";?>
  2. hello I am working on a simple script to update a users password based on their email address. I do not need high security for this password change, it is behind an internal intrnet site. I do not get any errors when the script runs but it is not updating the password form to update <form action="/icloud/forgot/updateinfo.php" method="post"><input type="text" name="password"/><br> <font face="Arial, Helvetica, sans-serif">Change Email:</font><br/><input type="text" name="email" name="email"/><br/> <input type="submit" value="Update Email"/></form> and the backend updateinfo.php <?phpini_set('display_errors', 1);error_reporting(E_ALL); include("../sql.php");$result = mysql_query("SELECT * FROM users")or die(mysql_error());while ($row = mysql_fetch_array($result)){ $email = $row['email']; $password = $_POST['password'];}$sql = "UPDATE `users` SET `password` = '$password' WHERE password='$password' AND email='$email' ''";mysql_query($sql) or die ("Error: ".mysql_error());echo "Database updated. <a href='update_email.php'>Return to edit info</a>";?>
  3. one more question, with the drop down selecting the 3 rows I am using this as a sort of address book. The users load the Nname Cname and address on another page then when they are filling out a form I want them to be able to use the drop down to make a selection. So is it possible to have it post that information it is pulling back into the database into the 3 different rows? Nname Cname address
  4. forget that I had accidently put a . after the $option
  5. thanks for the reply with the code above I am gttin this error Parse error: syntax error, unexpected ';' in /homepages/37/d381229304/htdocs/go-servers/icloud/addressbook.php on line 17 <?phpinclude("sql.php");include("auth.php");$UID = $_SESSION['UID'];$sql="SELECT * FROM users where UID='$UID' AND Cnumber != ''";$result=mysql_query($sql);//$options="";while ($row=mysql_fetch_array($result)) {$id=$row["Nname"];$thing=$row["Nname"];[/b][b]$options.="<OPTION VALUE=\"$id\">".$thing." ".$row["CNumber"]."".$row["address"]."</option>";}?><SELECT NAME=Nname><OPTION VALUE=0>Choose<?=$options.?></SELECT>
  6. How would I display the 3 rows in the dropdown? With the current code I have it only shows one row Nname but in the dropdown I need Nname Cname address to all be displayed Thanks
  7. Hello I am trying to figure out how to create a drop down that pulls from 3 rows, I can pull a single value with the code below but I cannot figure out how to mull the other values <?include("sql.php"); include("auth.php"); $UID = $_SESSION['UID'];$sql="SELECT * FROM users where UID='$UID' AND Cnumber != ''";$result=mysql_query($sql);$options="";while ($row=mysql_fetch_array($result)) { $id=$row["Nname"]; $thing=$row["Nname"]; $options.="<OPTION VALUE=\"$id\">".$thing;}?><SELECT NAME=Nname><OPTION VALUE=0>Choose<?=$options?></SELECT> so in the dropdown I would need it to pull for each option Nname CNumber address
  8. joshuaer

    Sendmail Help

    ok discard that, got it workin $txt .= "\r\n".' '.$row['list'] . ' ' . $row['type'].$row['amount'];
  9. joshuaer

    Sendmail Help

    Thank you very much that worked great can I get one more thing, how can I get it to break after each line $txt .= ' '.$row['list'] . ' ' . $row['type'].$row['amount']; i tried /r/n but it did not break each line
  10. joshuaer

    Sendmail Help

    How do I add each row to the same variable? Thanka again
  11. joshuaer

    Sendmail Help

    Does this look correct to how you where describing to do it justsomeguy? Thanks <?phpini_set('display_errors', 1);error_reporting(E_ALL);include("sql.php"); //Connect to SQLinclude("auth.php"); //Connect to SQL$UID= $_SESSION['UID'];$headers = 'test';$d = date ("D");$result = mysql_query("SELECT * FROM users where UID='$UID' AND list != ''");$sel = mysql_query("SELECT * FROM users where UID='$UID' AND email != ''");$mail_hrd = "From: test list;"; $txt = "your test list - ";if(mysql_num_rows($result) > 0){$count = 0;while ($rows = mysql_fetch_array ($sel, MYSQL_ASSOC)){$to = $rows['email'];while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)){$message = $txt . $row['list'].' ' . $row['type'];}}mail($to, $headers, $message, $mail_hrd);$count++;echo "myResult=$count Emails Sent. Done.";print $to;echo "$to";print $message;//print $day;}else{echo "myResult=Email Submissions Failed.";}?>
  12. joshuaer

    Sendmail Help

    Thanks for the response and sorry for the delay in response The list it is creating is a grocery type list, I am trying to create a button that emails the list to the email address the user has associated with its unique id. my rows are ID | username | password | list | UID | email | type | amount01 testuser 123456 1234567 test@test.com 02 bread 1234567 pkg 103 milk 1234567 gal 1 So the email I would like for it to contain the List, type and amount information
  13. joshuaer

    Sendmail Help

    I want to send a single email with everything in it
  14. joshuaer

    Sendmail Help

    Thank you for the help I added the second query and it is now pulling the first row of the list not looping through the rows to get all of the list associated with the user id <?phpini_set('display_errors', 1);error_reporting(E_ALL);include("sql.php"); //Connect to SQLinclude("auth.php"); //Connect to SQL$UID= $_SESSION['UID'];$headers = 'header';$d = date ("D");$sel = mysql_query("SELECT * FROM users where UID='$UID' AND email != ''");$result = mysql_query("SELECT * FROM users where UID='$UID' AND iChore1 != ''");$mail_hrd = "From: ;"; $txt = "Your List ";if(mysql_num_rows($result) > 0){$count = 0;while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)){$message = $txt . $row['list'].' ' . $row['type'];while ($rows = mysql_fetch_array ($sel, MYSQL_ASSOC)){$to = $rows['email'];mail($to, $headers, $message, $mail_hrd);$count++;}}echo "myResult=$count Emails Sent. Done.";}else{echo "myResult=Email Submissions Failed.";}?>
  15. joshuaer

    Sendmail Help

    Hello I am trying to create a sendmail script that pulls a list that a user has created out of a database that is associated with their user id and sends it to the email associated with their user id, Each item they add is put into a row called list and the userid for the person who is creating the item is also put in a row called userid I can get it to send the email to the users email address but it is not pulling the rows for that user, can someone help point me in the right direction please Thank you <?phpini_set('display_errors', 1);error_reporting(E_ALL);include("sql.php"); //Connect to SQLinclude("auth.php"); //Connect to SQL$UID= $_SESSION['UID'];$headers = 'header';$d = date ("D");$result = mysql_query("SELECT * FROM users where UID='$UID'");$mail_hrd = "From: ;"; $txt = "Your List ";if(mysql_num_rows($result) > 0){$count = 0;while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)){$message = $txt . $row['list'].' ' . $row['type'];$to = $row['email'];mail($to, $headers, $message, $mail_hrd);$count++;}echo "myResult=$count Emails Sent. Done.";}else{echo "myResult=Email Submissions Failed.";}?>
  16. OOOOOOO.....light bulb! Thanks I finally understand
  17. I could not figure out how to exclude a row using the WHERE function
  18. ok I changed my select to $result = mysql_query("SELECT Nname,address,iChore1 FROM users where UID='$UID'")or die(mysql_error());and it seems to work but I still get a blank row, but it does not allow me to delete that empty row now so it looks like that should work for what I need Thanks allot
  19. I tried this alsocame up with the same results <?php while ($rows = mysql_fetch_array($result, MYSQL_ASSOC)):?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="need_delete[<? echo $rows['ID']; ?>]" type="checkbox" id="checkbox[<? echo $rows['ID']; ?>]" value="<? echo $rows['ID']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['ID']; ?></td> <?php if('Nname'== "NULL") unset($rows); ?> <td bgcolor="#FFFFFF"><? echo htmlspecialchars($rows['Nname']); ?></td> <td bgcolor="#FFFFFF"><? echo htmlspecialchars($rows['address']); ?></td> <td bgcolor="#FFFFFF"><? echo htmlspecialchars($rows['iChore1']); ?></td> </tr><?php endwhile; ?>
  20. Thanks birbal it is now showing data but still showing the empty row
  21. Ok so I am trying the if empty command but it is not showing any results at all now, $emptyNname='Nname'; <?php if (empty($emptyNname)):?><?php while ($rows = mysql_fetch_array($result, MYSQL_ASSOC)):?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="need_delete[<? echo $rows['ID']; ?>]" type="checkbox" id="checkbox[<? echo $rows['ID']; ?>]" value="<? echo $rows['ID']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['ID']; ?></td> <td bgcolor="#FFFFFF"><? echo htmlspecialchars($rows['Nname']); ?></td> <td bgcolor="#FFFFFF"><? echo htmlspecialchars($rows['address']); ?></td> <td bgcolor="#FFFFFF"><? echo htmlspecialchars($rows['iChore1']); ?></td> </tr><?php endwhile; ?><?php endif; ?>
  22. Justsomeguy.... Can I add more fields I want to include by adding AND?UID=$UID AND Nname AND address AND Cname
  23. Hello I am trying to figure out what the best way to hide a row when the Nname field is empty currently if the Nname field is empty the row still shows up in my query showing the ID number, but I would like to suppress this row all together Here is the code I currently have <?phpini_set('display_errors', 1);error_reporting(E_ALL); $host = ''; $username = ''; $password = ''; $db_name = ''; $tbl_name = ''; mysql_connect($host, $username, $password) or die('cannot connect'); mysql_select_db($db_name) or die('cannot select DB'); include("auth.php"); $UID = $_SESSION['UID'];$result = mysql_query("SELECT * FROM users where UID='$UID'")or die(mysql_error());// $sql = 'SELECT * FROM `'.$tbl_name.'`';// $result = mysql_query($sql);?><table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td> <form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> </tr><?php while ($rows = mysql_fetch_array($result, MYSQL_ASSOC)): ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="need_delete[<? echo $rows['ID']; ?>]" type="checkbox" id="checkbox[<? echo $rows['ID']; ?>]" value="<? echo $rows['ID']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['ID']; ?></td> <td bgcolor="#FFFFFF"><? echo htmlspecialchars($rows['Nname']); ?></td> <td bgcolor="#FFFFFF"><? echo htmlspecialchars($rows['address']); ?></td> <td bgcolor="#FFFFFF"><? echo htmlspecialchars($rows['iChore1']); ?></td> </tr><?php endwhile; ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr><?php if ( ! empty($_POST['delete'])) { foreach ($_POST['need_delete'] as $id => $value) { $sql = 'DELETE FROM `'.$tbl_name.'` WHERE `id`='.(int)$id; mysql_query($sql); } //header('Location: ichores.php'); exit(); } mysql_close(); ?> </table> </form> </td> </tr></table>
  24. Hello I am trying to figure out how to delete multiple rows with php script. I found several methods searching the internet but I came across one article that lays out the entire script for you http://www.phpeasyst...om/mysql/8.html So I created the test database and used the script provided. It all seemed to be going well, it does not throw up any errors at any point of the script but when I choose the rows I want to delete and clock delete it just refreshes the page and does not remove any of the rows This is the code I am using, I was hoping someone might be able to point me in the direction to try and figure out what I am doing wrong. Thanks <?php$host="."; // Host name$username=""; // Mysql username$password=""; // Mysql password$db_name=""; // Database name$tbl_name="test_mysql"; // Table name // Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect");mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name";$result=mysql_query($sql); echo '<meta name="viewport" content="width=device-width; initial-scale=1.0">'; $count=mysql_num_rows($result);?> <table width="400" border="0" cellspacing="1" cellpadding="0"><tr><td><form name="form1" method="post" action=""><table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"><tr><td bgcolor="#FFFFFF"> </td><td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td></tr><tr><td align="center" bgcolor="#FFFFFF">#</td><td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td><td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td><td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td><td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td></tr> <?phpwhile($rows=mysql_fetch_array($result)){?> <tr><td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td><td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td><td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td><td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td><td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td></tr> <?php}?> <tr><td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td></tr> <?php // Check if delete button active, start thisif($delete){for($i=0;$i<$count;$i++){$del_id = $checkbox[$i];$sql = "DELETE FROM $tbl_name WHERE id='$del_id'";$result = mysql_query($sql);}// if successful redirect to delete_multiple.phpif($result){echo "<meta http-equiv=\"refresh\" content=\"0;URL=test.php\">"; }} mysql_close();echo "$checkbox"?> </table></form></td></tr></table>
  25. joshuaer

    PHP MySql Help

    Yes that code worked.. Thank you So Called and also thank you Just Some Guy, I understand how it should be working now. I appreciate both of your help
×
×
  • Create New...