Q re Include & how it works - newbie

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


Like it says' newbie to PHP.

Perhaps someone could provide me with a plan language of how Includes
   In my reading, it says you place the Include(somefile) and it's as
though that file were suddenly at that point of whatever file is
including it.  OK, sort of makes sense and I can see it happen in the
sandbox. Pretty standard stuff, I think.

Without lots of code, let's take a program like this:
1.  Show captcha image.php and its textbox only
    a. validate captcha image.php code - stay at one until captcha code
is good, then go to fill-                in.php.

2.  Fill-in.php
    a. Includes Fill-InCheck.php.
    b. Fill-inCheck.php Validates filled in fields in fill-in.php and
either stays at fill-in.php or when         all fields are properly
validated, go to result.php.

3. result.php displays the data sent onscreen for eyeball verification
and then sends the data.

I'm doing fine displaying the captcha code image and verifying that the
entered code is good, then moving on to display fill-in.php, which is
where the actual data to be emailed is filled in.

But that's where I fall apart.  After filling in the fields in
fill-in.php, I can't seem to get it to use the included file
fill-inCheck.php and then go to result.php to send the mail.
   More precisely, Right now fill-inCheck.php has nothing in it but an
echo "I'm here" line to show that the Include worked (no validation is
being done), but the intent is for it to send the data to result.php of
course, for emailing.  But the ONLY way I can seem to get it to go to
result.php is to use Action="result.php" in the <Form's Input line where
it should be just "" so it will post back to istelf in the event of
future validation errors.  And if I do that, of course, there is no data
to be emailed; just the field names and empty fields.  I have also
preloaded two of the 4 fields with data just to make testing quicker.

Maybe that all makes no sense; I'm hoping it does.  Basically, the idea
is to:
1.  Do the captcha code business first, and then
2.  Collect that data, validate it and e-mail the data.
Like I said, pretty standard stuff, I think.

The code is actually relatively short so I'll post the relevant pieces
in the hopes it'll help.  If seeing the entire code and all files will
help I can stage them in their entirety on my web site; just let me
   Some of the code might be a little flaky; I've been shotgunning more
than I should and it's time to start with another rewrite, I think,
using my first working model that succeeded.
   Reason not want to use first working model:  This set of forms is
long and I want the main captcha business out of the way earlier, and
then there will be a couple more simply human-tests at the end of the
   About the only restriction I have right now is no javascript and
server-side as much as possible.



<!-- fillIn.php is a NEW FILE  -->
<!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 ">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
<!--  resetta javascript removed -->

<div class="content">
 id="fillInForm" name="fillInForm" method="post" action="">

<H2> fillIn.php </H2>
<div class="row"><label for="email">Email Address: </label>
<input name="email" type="text" id="email" size="60" value= "My email
value="<?php if(isset($_POST['email'])){echo $_POST['email'];} ?>"

<div class="row"><label for="city">Your City: </label>
<input name="city" type="text" id="city" size="30"
value="<?php if(isset($_POST['city'])){echo $_POST['city'];} ?>" />


<div class="row"><label for="reset"> </label
<input type="reset" name="Reset" id="reset" value="Clear everything; I
want to start over"

<div class="inp" style="text-align:center"><label
<input type="submit" name="fillInForm" id="fillInForm" value="Submit
E-Mail" /></div>



echo This_Is_RESULT.PHP_being_INcluded


/* result.php WAS result1.php */
if(isset($_SESSION['post'])){$post =

if(isset($post['email'])){$_email = $post['email'];}else{$email = '';}

if(isset($post['city'])){$_city = $post['city'];}else{$_city = '';}


echo "Email Address:<br> \"" . $_email . "\" <br>";
echo "City:<br> \"" . $_city . "\" <br>";
$mailuser = " ...... "

$header = "Return-Path: ".$mailuser."\r\n";
$header .= "From: Web Site <".$mailuser.">\r\n";
$header .= "Content-Type: text/html;";

$mail_body = '
User: '. $_email .' submitted  Form.
city: '. $_city . '<br>

 mail ($mailuser, 'Form sent', $mail_body, $header);

<p align="center"></p><a href="http://www. ...">RETURN to ?? </a>

Re: Q re Include & how it works - newbie

Twayne wrote:
Quoted text here. Click to load it

include is just the same as if you copied and pasted the code into the
including page.

Quoted text here. Click to load it

Did you look at the source code in your browser?  You're outputting the
text in fillInCheck.php before anything - including the doctype.  This
makes your entire page invalid.  Browsers might now show it.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline