At 3:50 PM -0400 5/26/10, Alice Wei wrote:

My bad, I cannot imagine I sent that stuff. To answer your question, here it is,

                <form action="" method="post">
                <p>Select the type of your starting point of interest:<br/>
<input type="text" name="start" size="20" maxlength="50"/>

                   <input type="submit" value="submit" name="submit"></p>

This is what is working now if I do it this way, but again, then I got to make sure everything is "typed up properly" before the form is submitted. Does this answer your questions by any chance?



Okay, not bad -- here's my addition:

Please review the code. I removed the maxlength because that's something you should do server-side anyway. Never trust anything coming from the client-side.

Also note that closing the tags, such as <br/> is optional -- IF -- you're not planning on using XML. Otherwise they will generate a W3C short-tags warning. However, that's not a fatal error.

Also note the Submit button statement has three attributes. Type states the type of input statement, value is what the button displays to the user (i.e., Submit") and name is the name of the variable that you can access via a POST/GET.

Also note how the form collects the "start" value from a POST and then repopulates the form after it has the data. This important to understand. Clicking the "Submit" button sends the form's data to the server which then sends it back to the browser via a refreshed form.

Also note the ternary operator I used, namely:

$start = isset($_POST['start']) ? $_POST['start'] : null;

The first time the page is viewed, POST is sampled for content. If there is no content, then checking for content will generate an error unless we first check to see if it has content, hence the isset(). If it doesn't have content, then the statement assigns NULL to $start. If it does have content, then it will assign that value to $start, understand?

Now, what's next? What other data do you want to collect? You mentioned a select control that derived its data from a database. But before we go to that, show me a "select" control working in a form with embedded values -- in other words, just a simple select control. Please add it to the form we have.




PHP General Mailing List (
To unsubscribe, visit:

Reply via email to