Jump to content

eagle1771

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

About eagle1771

  • Birthday 10/04/1951

Profile Information

  • Gender
    Male
  • Location
    Indianapolis, IN

eagle1771's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am a struggling 'newbie' programmer and could really use some help. I know I am probably making some basic mistakes and I think I may have some redundant code in here. I have reduced the original file size down to the basics - from nearly 2000 lines of code to about 300. The purpose of this Php web page is as follows: 1) Check for properly logged in user 2) Set a $user variable based on the session username value 3) Query the db for logged in user info and assign values to the variables for populating the form fields 4) Display the update form with current db info allowing user to change and click update button 5) Test for errors and redisplay form with errors flagged for correction 6) Query updated db and display (echo) results 7) Provide a button to return to the form for further updating As it stands right now, if I comment out the error checking code which is for the excellent validation script at: http://www.benjaminkeen.com/software/php_validation/ the script works but of course works even when errors are made in the data entry. With the error checking left in, when the form is submitted it goes to a blank black screen (background color) and does not update the db. Thanks in advance for any light you can shed on my efforts. I am attaching the code as a text file. [attachment deleted by admin]
  2. Hello Ancoats, I am fairly new to Php programming, but the only two things I noticed are: 1) Your form action structure looks unusual (at least to me). What exactly does it do? <form action="<?php echo $dir;?>editprofile.php<?php echo $row->memberID;?>" method="post"> 2) I don't think Php should care, but I noticed in some of your form fields you are leaving off the slash and doing ;?>"> instead of ;?>"/>
  3. I have been working on a rather large (58k) php web page to allow users of our web site to update their own user profile. I believe that I am close to having this working but I must have some structural errors as I am unable to get the error checking to work and to get the script to be stable and give the expected results for any user. The script does the following: 1) Check for properly logged in user 2) Set a $user variable based on the session username value 3) Query the db for logged in user info and assign values to the variables for populating the form fields 4) Display the update form with current db info allowing user to change and click update button 5) Test for errors and redisplay form with errors flagged for correction 6) Query updated db and display (echo) results 7) Provide a button to return to the form for further updating Here is a link to my profile as required by the rules for this forum: http://www.phpfreaks.com/forums/index.php?action=profile;u=56476 As it stands right now, if I comment out the error checking code which is for the excellent validation script at: http://www.benjaminkeen.com/software/php_validation/ the script works but of course works even when errors are made in the data entry. With the error checking left in, when the form is submitted it goes to a blank black screen (background color) and does not update the db. If you want me to, I can remove everything except the relevant code to make the attached file much smaller and easier to check. I would really appreciate any help you can give as I have been working on this for about three weeks and am beginning to lose track of what I have done. I think I am going in circles. Thank you for taking a look. [attachment deleted by admin]
  4. Can anyone tell me if the following code makes sense, or is the rest of the script going to run regardless of whether the captcha test is a success or a failure (not a match)? // more code above; // test for valid captcha; if(isset($_POST["captcha"])) //If CAPTCHA is NOT valid - display error message for additional user input; if ($_SESSION["captcha"]!==$_POST["captcha"]) { echo $captcha_failure_message; } elseif ($_SESSION["captcha"]==$_POST["captcha"]) { //CAPTCHA is valid - write to database and send email; echo $captcha_success_message; } endif // script continues; Thanks, Ralph Moore
  5. moselkady, I tried using the "exit;" statement and it certainly does exit the script. I end up with my error statement displayed on a blank page. What I am trying to accomplish is to allow the visitor to correct their error and then continue with their form submission. That is why I thought I might need something along the lines of an IF statement. Like, IF the error exists loop until the error is corrected, and then continue with the script. Any ideas on how to do this? Thanks. Ralph Moore
  6. Barand, Can you show me an example of how to use that in my code? Thanks. Ralph Moore
  7. Hello Everyone, In my spare moments I have been trying to learn Php and a little MySQL. I have a script which writes the contents of a form to a database and emails me the results, after checking the CAPTCHA form field input. The problem that I am having is that regardless of the results of the Captcha test, the script continues as if the Captcha test was a success instead of a failure. Do I need a WHILE or a FOR statement? I kind of know what the problem is but not how to write it. Here is the relevant code: <?php error_reporting(E_ALL); session_start(); $errors = array(); // set the errors array to empty, by default $fields = array(); // stores the field values $success_message = ""; $captcha_success_message = "CAPTCHA was entered correctly - Thank You"; $captcha_failure_message = "CAPTCHA was entered incorrectly - Please try again"; // more code, etc; // test for valid captcha if(isset($_POST["captcha"])) if($_SESSION["captcha"]==$_POST["captcha"]) { //CAPTCHA is valid write to database and send email; echo $captcha_success_message; } else { echo $captcha_failure_message; } // create variables from form data if ($_POST) { foreach($_POST as $fn => $v) { $v = trim($v) ; $$fn = $v ; } } // make connection to server, email results, etc.; ?> Thank you in advance for any help. Ralph Moore
  8. I think I found the problem. I actually needed a second "}" to close the "if" code. I think php was looking for that and threw an unexpected end (of file or routine) because it did not know how else to handle it. Anyway, it now displays with the added code where it would only give me a blank screen before. Thanks for all the help. I'm sure I will have more questions later.
  9. What I am seeing on line 543 is the final </html> closing tag and that is the end of the file. Do I need to then add another bit of code like this?: <?php ?> And if so, what exactly are the rules regarding mixing html and php? I have seen examples that seem to suggest that as long as you name the file with a php extension, it doesn't matter how you start or end the file as long as each set of starting and ending php tags are a complete set.
  10. cooldude832, Here is the relevant line from the web host error logs: [sat Nov 24 12:33:34 2007] [error] PHP Parse error: syntax error, unexpected $end in /home/wchs1969/wchs1969-www/newaddreg.php on line 543 Uh, when I look in the code, there is no $end that I can see... anywhere. Any suggestions?
  11. I ran phpinfo() a long time ago and while display_errors is off, I have added ini_set('display_errors', 2048); right below the opening php tag "<?php" - which is supposed to do the same thing on a per script basis. I'm not seeing any errors. I can also look at the error log in the web host control panel, and while it does show php errors from time to time whenever I 'tweak' the code, it is not meaningful, at least to me.
  12. That section of code is shorthand (I think). What it says is loop through the entire form and assign variable variables for each named field name / value pair and then use trim to get rid of any leading or trailing spaces. It's from page 104 of the second book I mentioned. Anyway, I know it does work, when coupled with the form and the email function, because I did in fact get the form to email me the results.
  13. I just realized that the code was not displaying properly in the code blocks. Here they are. <?php echo 'Hello, world!'; ?> <?php //create variables from form data if ($_POST) { foreach($_POST as $fn => $v) { $v = trim($v) ; $$fn = $v ; } echo 'Hello, world!'; ?>
  14. Greetings Php Helpers, I am about ready to start pulling out (what's left of) my hair. I am new to php programming and could use some help. I have spent a huge amount of time reading through three php books and searching through the forums, tutorials, code examples, etc. here before asking this question. I am also betting that there are a LOT of php 'newbies' that struggle with this same problem. (And yes, I have looked at "syntax" in the Php manual). I have written a rather large form at http://www.wchs1969.com/newaddreg.php Here's the problem. The form displays properly as an html page. It even displays properly with the following php code placed just before the closing "</body>" tag in the web page. <code> <?php echo 'Hello, world!'; ?> </code> Now when I change the php portion of the code to this: <code> <?php //create variables from form data if ($_POST) { foreach($_POST as $fn => $v) { $v = trim($v) ; $$fn = $v ; } echo 'Hello, world!'; ?> </code> I get a blank page. My question, of course, is why? I realize that this is probably a syntax error or that the php processor does not know what to do with this new code. I have been looking all over for something that explains the syntax 'rules' for php and I cannot seem to find what I am looking for. The actual code that I was trying to add to this form is much more extensive than the small amount that I posted above, as it is intended to do some error checking of email addresses, required fields, etc., as well as posting to a database, but I finally just cut it down to try to get the form to display. Can someone please point me to an explanation of what I am probably doing wrong (or just explain it here)? I have used NoteTab Pro and WeBuilder 2007 (purchased) to write the php code. This is being done on a fairly new Toshiba Satellite P105-S6147 with 2Gb ram and (unfortunately) Windows Vista Ultimate. The web host is Host4Profit.net I am using WS_Ftp Pro for file transfer. If needed, I will be happy to post the entire php code as well as the html code, in two separate text files, or however you prefer. And the three books that I mentioned above are: PHP Fast & Easy Web Development 2nd Edition by Julie C. Meloni - pretty good teach yourself PHP with MySQL by Nat Macbride - also good PHP and MySQL for Dynamic Web Sites 2nd Edition Visual QuickPro Guide by Larry Ullman - Excellent (in my newbie opinion) Thank you. Ralph Moore would-be php programmer
  15. Doh! I Must have looked at that field name ten times (at least) and even when I read it this time, I almost missed the extra "t". I had lasttname there. You are definitely "the man"! Thank You! I REALLY appreciate the help. I will mark this as solved. Raph Moore
×
×
  • 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.