Jump to content

amplexus

Members
  • Posts

    55
  • Joined

  • Last visited

    Never

Everything posted by amplexus

  1. the site is hosted by Godaddy. is there a way to turn something like that off?
  2. okay, have to revive this thread. what I've discovered when I gave this to the client is that they LOVE to use contractions in their copy. Every time they put an apostrophe, PHP puts a backslash, so it's becomes it\'s. is there a way to tell php that this is a .txt file it is writing to?
  3. Hi again, I've got a php include for a Navigation list, and I'm trying to get it to add the id tag to the current page. my code looks like this: <a href="order.php"<?php if ($currentpage == 'order.php') {echo 'id="here"';} ?>>Order Lobsters</a> |<a href="about.php"<?php if ($currentpage == 'about.php') {echo 'id="here"';} ?>>About Us</a> |<a href="crew.php"<?php if ($currentpage == 'crew.php') {echo 'id="here"';} ?>>Our Crew</a> |<a href="rental.php"<?php if ($currentpage == 'rental.php') {echo 'id="here"';} ?>>Rental Property</a> |<a href="contact.php"<?php if ($currentpage == 'contact.php') {echo 'id="here"';} ?>>Contact Us</a> |<a href="facility.php"<?php if ($currentpage == 'facility.php') {echo 'id="here"';} ?>>Our Green Facility</a> I'm not getting any errors, just not working. if I remove the "if" statement, the echo works, so I know my problem is there. maybe I have the wrong syntax for the page name string? where is it looking to get that information? I've only tested on my local xampp server, but these are relative links, no? thanksi n advance for your help.
  4. and so I've got this, and thank you for the changing names idea, I also figured out that I needed to change the textarea name. it seems to be working okay... <body> Edit copy for Homepage to appear as you want on the website, then click "update" <? if($_POST['home']){ $open = fopen("index.txt","w+"); $text = $_POST['hometext']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../index.php">View Live Results</a><br /> <br /> <br /> <? $file = file("index.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("index.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"hometext\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"home\" type=\"submit\" value=\"Update Homepage\" />\n </form>"; } ?> Edit copy for About Us page to appear as you want on the website, then click "update" <? if($_POST['about']){ $open = fopen("about.txt","w+"); $text = $_POST['about_text']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../about.php">View Live Results</a><br /> <br /> <br /> <? $file = file("about.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("about.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"about_text\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"about\" type=\"submit\" value=\"Update about us\" />\n </form>"; } ?> Edit copy for Rental Property Page to appear as you want on the website, then click "update" <? if($_POST['Stental']){ $open = fopen("rental.txt","w+"); $text = $_POST['rental_text']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../rental.php">View Live Results</a><br /> <br /> <br /> <? $file = file("rental.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("rental.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"tental_text\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"rental\" type=\"submit\" value=\"Update Rental Text\" />\n </form>"; } ?> Edit copy for Crew to appear as you want on the website, then click "update" <? if($_POST['crew']){ $open = fopen("crew.txt","w+"); $text = $_POST['crew_text']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../crew.php">View Live Results</a><br /> <br /> <br /> <? $file = file("crew.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("crew.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"crew_text\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"crew\" type=\"submit\" value=\"Update Crew Text\" />\n </form>"; } ?> Edit copy for Order Lobsters to appear as you want on the website, then click "update" <? if($_POST['order']){ $open = fopen("order.txt","w+"); $text = $_POST['order_text']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../order.php">View Live Results</a><br /> <br /> <br /> <? $file = file("order.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("order.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"order_text\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"order\" type=\"submit\" value=\"Update Order Page Text\" />\n </form>"; } ?> which seems to be working fine. if you're so inclined, do you see any problems? I know about security,and will be adding a passcode protection before going "live"
  5. so, In the last bit you can see (I hope)that I've changed the first form to have a name of "home" and adjusted the $_POST value to "home" as well. this has the effect of changing just the one value, and leaving the other forms intact. however, it also seems to change the .txt value to a blank. I'm thinking that the fwrite value needs to be changed, am I barking up the right tree here?
  6. [code} <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> Edit copy for Homepage to appear as you want on the website, then click "update" <? if($_POST['home']){ $open = fopen("index.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../index.php">View Live Results</a><br /> <br /> <br /> <? $file = file("index.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("index.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"home\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"home\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for About Us page to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("about.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../about.php">View Live Results</a><br /> <br /> <br /> <? $file = file("about.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("about.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for Rental Property Page to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("rental.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../rental.php">View Live Results</a><br /> <br /> <br /> <? $file = file("rental.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("rental.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for Crew to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("crew.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../crew.php">View Live Results</a><br /> <br /> <br /> <? $file = file("crew.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("crew.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for Order Lobsters to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("order.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../order.php">View Live Results</a><br /> <br /> <br /> <? $file = file("order.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("order.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> </body> </html>
  7. I've replaced this thread with a new post that is modified. thx pikachu, I was too tired to remember to format correctly, my eyes were crossing, but I should have known better!
  8. Hi, I'm creating a website, and want to have text on a portion of each page be editable by a non-tech, average user. I've created a form, and I've got it to work. I'm using .txt files. what I've tried to do is create one page that has all of the pages' editable areas on it, each one displaying the current text, and a submit button to make the changes live. in the code, the php to generate the forms is after each of the text lines beginning with "Edit copy". Problem: when you click any of the submit buttons, all of the areas update. is it that i need to make each separate form code have a different input name? here;s my code, formatted to make it easier to read, since I was completely exhausted before. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> Edit copy for Homepage to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("index.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../index.php">View Live Results</a><br /><br /><br /> <? $file = file("index.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("index.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for About Us page to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("about.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../about.php">View Live Results</a><br /><br /><br /> <? $file = file("about.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("about.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for Rental Property Page to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("rental.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../rental.php">View Live Results</a><br /><br /><br /> <? $file = file("rental.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("rental.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for Crew to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("crew.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../crew.php">View Live Results</a><br /><br /><br /> <? $file = file("crew.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("crew.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for Order Lobsters to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("order.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../order.php">View Live Results</a><br /><br /><br /> <? $file = file("order.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("order.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> </body> </html> what's wrong?
  9. Hi, I'm creating a website, and want to have text on a portion of each page be editable by a non-tech, average user. I've created a form, and I've got it to work. I'm using .txt files. wht I've tried to do is create one page that has all of the pages' editable areas on it, each one displaying the current text, and a submit button to make the changes live. Problem: when you click any of the submit buttons, all of the areas update. here;s my code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> Edit copy for Homepage to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("index.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../index.php">View Live Results</a><br /><br /><br /> <? $file = file("index.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("index.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for About Us page to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("about.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../about.php">View Live Results</a><br /><br /><br /> <? $file = file("about.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("about.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for Rental Property Page to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("rental.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../rental.php">View Live Results</a><br /><br /><br /> <? $file = file("rental.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("rental.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for Crew to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("crew.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../crew.php">View Live Results</a><br /><br /><br /> <? $file = file("crew.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("crew.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for Order Lobsters to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("order.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../order.php">View Live Results</a><br /><br /><br /> <? $file = file("order.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("order.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> </body> </html> what's wrong?
  10. I'm pretty sure it's NOT the javascript causing the problem.
  11. so, you've set a variable $con to be mysql_connect, but you never actually tell it to connect. you also need some of this: mysql_select_db($database) or die( "Unable to select database")
  12. what I think is happening is that the referring page has a fairly simple javascript pass protect script (this isn't government secrets here) and when you don't don't enter the right code, it somehow runs the script without displaying? here's the referring page code, and the javascript as well <head> <SCRIPT language="JavaScript" src="logscript.js"> </SCRIPT> <link href="cathfound.css" rel="stylesheet" type="text/css" /> </HEAD> <?php session_start(); $_SESSION['logged'] = 1; include("dbinfo.inc.php"); mysql_connect($servname,$dbusername,$dbpassword); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM ($newdbname)"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Username</font></th> <th><font face="Arial, Helvetica, sans-serif">Password</font></th> </tr> <? $i=0; while ($i < $num) { $username=mysql_result($result,$i,"username"); $password=mysql_result($result,$i,"password"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><? echo "$username"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$password"; ?></font></td> </tr> <? ++$i; } echo "</table>"; ?> <br/><br/><br/><br/><a href="update.php">Click here to update users</a> java script: var password; var pass1="xxxxxxxxxx"; password=prompt('Please enter your password to view this page!',' '); if (password==pass1) alert('Password Correct! Click OK to enter!'); else { window.location="/index.html"; }
  13. hi everyone. I'm using some session scripting to allow access to a page only from a page that is password protected.everything works just dandy, except for this... if someone is on the page, and refreshes, it destroys the session. requires the password. that part is okay. if you then enter the password incorrectly, you are bumped not to the original referring page, passlist.php, but to the site index. at that point from the site index, if you type the url into the bar, or use a shortcut, you are allowed passcode free access to the page. the site index is an html page, not PHP, and no session setting or variable passing can occur, right? here's the code on the original page, the one you can only get to through a referring page( at least, should only) <?php session_start(); if(empty($_SESSION['logged'])) { echo "<script>window.location.href='passlist.php'</script>"; } session_unset(); session_destroy(); include("dbinfo.inc.php"); mysql_connect($servname,$dbusername,$dbpassword); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM ($newdbname) "; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $user_id=mysql_result($result, $i, "user_id"); $username=mysql_result($result,$i,"username"); $password=mysql_result($result,$i,"password"); echo "$username, $password, $user_id"; ?> <form action="updated.php"> <input type="hidden" name="user_id" value="<?php echo "$user_id"; ?>"> Username: <input type="text" name="username" value="<?php echo "$username"?>"><br> Password: <input type="text" name="password" value="<?php echo "$password"?>"><br> <input type="Submit" value="Update" name="submit"> </form> <?php ++$i; } ?> I hope I'm explaining this correctly, I'm baffled.
  14. PFMaBiSmAd, With your patient help, and the help of others, I was able to get this to work ( thank you for being sorry enough to mention, but not enough to stop, picking ). I am now going to set out on the journey of refining, and also, fixing the little issues you have mentioned. Honestly, I was using PASSWORD only as a means of testing the hash function, and never intended this to go wild without changing to MD5(). I also knew about the repassing of the hash, and intended to tell the admin that they would need to re enter both values, but I like the check box idea. now you'll probably see another post about fixing check boxes in my code! ha ha. I'm posting my "final" code for this thread here, again, thank you so much to all for your patient help! <?php session_start(); include("dbinfo.inc.php"); mysql_connect($servname,$dbusername,$dbpassword); mysql_select_db($database) or die( "Unable to select database"); if(isset($_GET['user_id'], $_GET['username'], $_GET['password'])) { $ud_id = $_GET['user_id']; $ud_username = $_GET['username']; $ud_password = $_GET['password']; $query = "UPDATE `$newdbname` SET `username` = '$ud_username', `password` = PASSWORD('$ud_password') WHERE `user_id`= '$ud_id'"; $result = mysql_query( $query ) or die( mysql_error() ); if($result) { if(mysql_affected_rows() == 1) { echo 'Success! We have updated the username/password for the users id of -' . $ud_id; echo '<br /><br /><a href="update.php"> Click here to update more records</a>'; } else { echo 'Sorry, no rows were affected with the userid of - '. $ud_id; } } } else { echo 'Invalid data provided!<br /><a href="update.php">Chose a record to update</a>'; } ?>
  15. utterly defeated. I cannot make this work. I cannot understand what is wrong. I cannot seem to do anything that ever makes this better, only breaks it. I've read tutorials. I've read the manual. I've done a logical breakdown of what should be happening. I've followed every suggestion you have all given me. I am lost. and disheartened. here's my code. read it, and have a good laugh at me. <?php session_start(); include("dbinfo.inc.php"); mysql_connect($servname,$dbusername,$dbpassword); if(isset($_GET['user_id'])) { $ud_id = $_GET['user_id']; } if(isset($_GET['username'])) { $ud_username = $_GET['username']; } if(isset($_GET['password'])) { $ud_password = $_GET['password']; } //$query="UPDATE FROM $newdbname SET username ='$ud_username', password= PASSWORD('$ud_password') WHERE user_id='$ud_id'"; $query = "UPDATE FROM `$newdbname` SET `user_name` = '$ud_username', `password` = 'PASSWORD('$ud_password')' WHERE `user_id`= '$ud_id'"; $result = mysql_query( $query ) or die( mysql_error() ); mysql_select_db($database) or die( "Unable to select database"); mysql_query($query) or die("Query Error: " . mysql_error()); echo mysql_error(); printf ("Updated records: %d\n", mysql_affected_rows()); echo '</br><a href="update.php"> Click here to update more records</a>'; mysql_close(); ?> could someone with a heart please at least tell me if this is a simple problem? am I WAY off the mark, or really close, because, honestly, I can't tell anymore. James
  16. okay, I removed the @ symbol. I changed the code to the following, base on what I found in the link you posted me. $query="UPDATE [LOW_PRIORITY] [iGNORE] $newdbname SET username = {'$ud_username'}, {password= PASSWORD('$ud_password')} [WHERE user_id='$ud_id']"; mysql_select_db($database) or die( "Unable to select database"); mysql_query($query); and I get the 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 '[LOW_PRIORITY] [iGNORE] users2 SET username = {'test124'}, {password= PASSWORD('' at line 1Updated records: -1
  17. well, I put it in because I thought (apparently incorrectly) that it would make it look at all the rows. I think i was using the $query="SELECT * FROM ($newdbname) "; part from the first script as a referencing point on that, in terms of when to use an asterix
  18. okay, so the problem is in this line $query="UPDATE FROM $newdbname SET username ='$ud_username', password= PASSWORD('$ud_password') WHERE user_id='$ud_id'"; I get this error right syntax to use near 'FROM users2 SET username ='test124', password= PASSWORD('*22A99BA288DB55E8E23067' at line 1 I tried removing the asterix and got exactly same result. does this mean it is unnecessary?
  19. so, I've changed it to be: <?php session_start(); include("dbinfo.inc.php"); mysql_connect($servname,$dbusername,$dbpassword); if(isset($_GET['user_id'])) { $ud_id = $_GET['user_id']; } if(isset($_GET['username'])) { $ud_username = $_GET['username']; } if(isset($_GET['password'])) { $ud_password = $_GET['password']; } $query="UPDATE * FROM $newdbname SET username ='$ud_username', password= PASSWORD('$ud_password') WHERE user_id='$ud_id'"; @mysql_select_db($database) or die( "Unable to select database"); mysql_query($query); printf ("Updated records: %d\n", mysql_affected_rows()); echo '</br><a href="update.php"> Click here to update more records</a>'; mysql_close(); ?> and I still get the same url, and the same lack of updating...
  20. tried that fortnox. no dice. I wonder is it something in the second script that's not getting the info? the url of the second script ends like this: updated.php?user_id=11&username=test12y&password=*22A99BA288DB55E8E230679259740873101CD636&submit=Update so, the values are coming in, no?
  21. I got this as for my form, which is what I expected: test123, *22A99BA288DB55E8E230679259740873101CD636, 11<form action="updated.php"> <input type="hidden" name="user_id" value="11"> Username: <input type="text" name="username" value="test123"><br> Password: <input type="text" name="password" value="*22A99BA288DB55E8E230679259740873101CD636"><br> <input type="Submit" value="Update"> </form> BobD, *4CF4CFD025BD3576D2697FC15E11DAEA09C4652B, 10<form action="updated.php"> <input type="hidden" name="user_id" value="10"> Username: <input type="text" name="username" value="BobD"><br> Password: <input type="text" name="password" value="*4CF4CFD025BD3576D2697FC15E11DAEA09C4652B"><br> <input type="Submit" value="Update"> </form> chris, *23AE809DDACAF96AF0FD78ED04B6A265E05AA257, 9<form action="updated.php"> <input type="hidden" name="user_id" value="9"> Username: <input type="text" name="username" value="chris"><br> Password: <input type="text" name="password" value="*23AE809DDACAF96AF0FD78ED04B6A265E05AA257"><br> <input type="Submit" value="Update"> </form>
  22. here is what i see happening: in the first script, database is connected to, and $query is set as an action to pull all the info from the database $result is set to actually pull the info using $query $num is set as the total number of rows a while loop is set to make sure all results are returned and filled into the form. $user_id, $username, and $password are set as the corresponding values pulled form the database, and are displayed. the form allows for those values to be changed, and passes the values via the submit button to the next script. in the second script, database is connected to, and the values of $ud_id, $ud_username, and $ud_password are set to the values returned by the GET action. $query is set to UPDATE the values in the table WHERE the id equals the value returned by that GET action ($ud_id) database is connected to and $query is run the number of affected rows is displayed, along with a link to return and change more records. what am I missing? Is it just syntax? I'm not getting any errors, and I've already changed everything I can think of. help. me. please.
  23. while I would in no way like to discount the high value of the logic, wisdom and approach of PFMaBiSmAd, is there anyone out there who can give me a bit more help? I understand that you, PFMaBiSmAd, are getting me to learn more on my own, and as a teacher, I can certainly appreciate it. However, I am very frustrated right now, since I don't know which parts of my code to fix. I look up answers, and I change things. no avail. there is very little of my code that I have NOT changed at this point, and I don't know how to fix it, since I don't know what isn't happening. anybody feeling kind? first script(which includes the form): <?php session_start(); include("dbinfo.inc.php"); mysql_connect($servname,$dbusername,$dbpassword); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM ($newdbname) "; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $user_id=mysql_result($result, $i, "user_id"); $username=mysql_result($result,$i,"username"); $password=mysql_result($result,$i,"password"); echo "$username, $password, $user_id"; ?> <form action="updated.php"> <input type="hidden" name="user_id" value="<?php echo "$user_id"; ?>"> Username: <input type="text" name="username" value="<?php echo "$username"?>"><br> Password: <input type="text" name="password" value="<?php echo "$password"?>"><br> <input type="Submit" value="Update"> </form> <?php ++$i; } ?> aaaand the second script, designed to GET the input passed by the form via POST and UPDATE the database: <?php session_start(); include("dbinfo.inc.php"); mysql_connect($servname,$dbusername,$dbpassword); if(isset($_GET['user_id'])) { $ud_id = $_GET['user_id']; } if(isset($_GET['username'])) { $ud_username = $_GET['username']; } if(isset($_GET['password'])) { $ud_password = $_GET['password']; } $query="UPDATE * FROM $newdbname SET username ='$ud_username', password= PASSWORD('$ud_password') WHERE id='$ud_id'"; @mysql_select_db($database) or die( "Unable to select database"); mysql_query($query); printf ("Updated records: %d\n", mysql_affected_rows()); echo '</br><a href="update.php"> Click here to update more records</a>'; mysql_close(); ?>
  24. the idea is that the site admin can modify a user name and password. the hash is left in place just in case anyone gains access to the page, but is also applied if you change the password. I've changed the original script to this <?php session_start(); include("dbinfo.inc.php"); mysql_connect($servname,$dbusername,$dbpassword); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM ($newdbname) "; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $id=mysql_result($result, $i, "user_id"); $username=mysql_result($result,$i,"username"); $password=mysql_result($result,$i,"password"); //$real_name=mysql_result($result,$i,"real_name"); echo "$username, $password, $real_name"; ?> <form action="updated.php"> <input type="hidden" name="ud_id" value="<? echo "$id"; ?>"> Username: <input type="text" name="username" value="<? echo "$username"?>"><br> Password: <input type="text" name="password" value="<? echo "$password"?>"><br> <input type="Submit" value="Update"> </form> <?php ++$i; } ?> still no change in the records updated. also, I un-commented the session_start() in the second script. to no avail.
×
×
  • 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.