473,396 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

telling people which inputs they missed on a form

tolkienarda
316 100+
hi all

i've been beating my brains out on my moniter because i cant figure out what is wrong with my code. what i am doing is checking input from a form to make sure it is accurate and if it isn't then i print a new table row and tell the people which fields they need to change and apperently i am too stupid to figure this out (mabey cause my brains are scattered accross my office.)

anyway code section one form valiadation on remote php mailer page ron and Motoma helped me with this code. but it is alot different than what they posted

code summary
i start my session and set my $_SESSION[failed] to zero, this will be set to one if an invalid form entry is entered. $i is a counter that will set a $_SESSION variable to equal the form area inproperly filled out, the thanksurl thing is just my redirect url if there isn't an error then i mail this form and it goes to a confermation page.
Expand|Select|Wrap|Line Numbers
  1.     session_start();
  2.     $_SESSION[failed]=0;
  3.     $i=1;
  4.     while ($i<9)
  5.     {
  6.  
  7.     }
  8.     $ThanksURL = 'submitted.htm';
  9.     if (strlen(trim($_POST[email])) < 1)
  10.     {
  11.     $_SESSION[failed] = 1;
  12.     $_SESSION[$i] = 'email';
  13.     $i++;
  14.     $ThanksURL= "registration.php";
  15.     }
  16.  
  17.     if (strlen(trim($_POST[first_name])) < 1)
  18.     {
  19.     $_SESSION[failed] = 1;
  20.     $_SESSION[$i] = 'First Name';
  21.     $i++;
  22.     $ThanksURL= "registration.php";
  23.     }
  24.  
  25.     if (strlen(trim($_POST[last_name])) < 1)
  26.     {
  27.     $_SESSION[failed] = 1;
  28.     $_SESSION[$i] = 'Last Name';
  29.     $i++;
  30.     $ThanksURL= "registration.php";
  31.     }
  32.  
  33.     if (strlen(trim($_POST[address])) < 1)
  34.     {
  35.     $_SESSION[failed] = 1;
  36.     $_SESSION[$i] = 'Address';
  37.     $i++;
  38.     $ThanksURL= "registration.php";
  39.     }
  40.  
  41.     if (strlen(trim($_POST[city])) < 1)
  42.     {
  43.     $_SESSION[failed] = 1;
  44.     $_SESSION[$i] = 'City';
  45.     $i++;
  46.     $ThanksURL= "registration.php";
  47.     }
  48.  
  49.     if (strlen(trim($_POST[state])) < 1)
  50.     {
  51.     $_SESSION[failed] = 1;
  52.     $_SESSION[$i] = 'State';
  53.     $i++;
  54.     $ThanksURL= "registration.php";
  55.     }
  56.  
  57.     if (strlen(trim($_POST[zip_code])) < 1)
  58.     {
  59.     $_SESSION[failed] = 1;
  60.     $_SESSION[$i] = 'Zip Code';
  61.     $i++;
  62.     $ThanksURL= "registration.php";
  63.     }
  64.  
  65.     if (strlen(trim($_POST[how_much_submit])) < 1)
  66.     {
  67.     $_SESSION[failed] = 1;
  68.     $_SESSION[$i] = 'Submission Amount';
  69.     $i++;
  70.     $ThanksURL= "registration.php";
  71.     }
  72.  
up next the messy loop that tells people which fields they missed on their first try.

code summary
the $_SESSION[fialed] variable will determine if the person has failed to fill out this form once before.
the loop then goes through all of the errors that i assigned earlier, exaple if they forgot to fill out the first name and zip code portions then $_SESSION[1] would be set to 'first name' and $_SESSION[2] would be set to 'zip code'
Expand|Select|Wrap|Line Numbers
  1. <?
  2. if ($_SESSION[failed] = 1)
  3. {
  4. echo "<tr>";
  5. echo "<td>";
  6. echo "please fill in the&nbsp;";
  7. $i = 1;
  8. while (isset($_SESSION[$i]))
  9. {
  10. echo $_SESSION[$i] "&nbsp";
  11. $i++;
  12. }
  13. echo "fields";
  14. echo "</td>";
  15. echo "</tr>";
  16. }
  17. ?>
  18.  
  19.  
Now the problem i am having is when i upload the page nothing displays and when i view the source code it is also blank.
when i just open the file on my computer it showes bits of the php code at the top of my form here is the jumble of mess it displays

"; echo ""; echo ""; } ?>
"; echo "please fill in the "; $i = 1; while (isset($_SESSION[$i])) { echo $_SESSION[$i] " "; $i++; } echo "fields"; echo "



Thanks for any and all help
eric
Jan 31 '07 #1
2 1376
tolkienarda
316 100+
hi

ok so i found a few problems which seem to fix that problem

the problem was in my display script where i try to make a new tr and td. apparently that isn't allowed but anyway now the page will load online but it is still going into that first if statement where i ask if $_SESSION[failed] is equal 1 now i am just comming back to my form page after i click the button and the error message dosen't tell me which form fields are incorrect. i have added another equal sign in my if statement because i had to when i used to program in c++ but it didnt help.

i changed the form valation script to take out the empty loop

if you are confused by my question because i tend to ramble and get spacy post calling me stupid and i will try to refrase everything
Jan 31 '07 #2
tolkienarda
316 100+
I don't know how to delete my post but this one is has so much crap in it that you should just ignore it and i will repost sometime when i am thinking straight.

sorry
eric
Feb 1 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Froggy | last post by:
I figured out that my java webserver goes crazy if I try to pass it more than 100 inputs from a single form at a time. The issue is that I need to have somewhere around 120~150 inputs (i am making...
1
by: Az Tech | last post by:
Hi people, (Sorry for the somewhat long post). I request some of the people on this group who have good experience using object-orientation in the field, to please give some good ideas for...
2
by: Chris Beach | last post by:
Hi there. I'd like to be able to group together inputs on an HTML form inside, say, a <div> or <fieldset> and then use javascript to iterate through the controls in the group and disable them....
11
by: Sven Neuberg | last post by:
Hi, I have been handed the task of updating and maintaining a web application, written in ASP and Javascript, that takes complex user inputs in HTML form and submits them to server-side ASP...
6
by: R. Rajesh Jeba Anbiah | last post by:
Is it necessary or is there any standard to send HTTP header status for form inputs ? Say, the user is entering invalid password in login form and now all the applications I have seen are just...
10
by: giancarlodirisioster | last post by:
Can someone help me modify this for future Usenet archival and to help me solve what I don't know? <form name="addform" method="POST" action="./submit.php"> <input type="text" name="Box 1"...
2
by: NotGiven | last post by:
I have a database result set with names, IDfield and a Y/N field. How do I create the radio buttons that can then be processed easily using an array (I assume) with an easy-to-loop-through...
4
by: StevensSpam | last post by:
How do I retrieve user inputs from web page into the C# program that is running behind? I am using Visual Studio to create an ASP.NET web application with code behind (aspx.cs) feature. Also, how...
2
by: sparks | last post by:
Well we just finished a monster database for a group at work. On one section, they wanted us to give them a filtered listing of people based on 2 other criteria. So we used filters and contiguous...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.