Closed Thread Icon

Topic awaiting preservation: PHp Forms (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12558" title="Pages that link to Topic awaiting preservation: PHp Forms (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHp Forms <span class="small">(Page 1 of 1)</span>\

 
Trigger
Paranoid (IV) Inmate

From:
Insane since: Jun 2002

posted posted 12-22-2002 22:35

Im learning.. PHP of the internet.. while im waiting to get my "php" book for christmas.
anyway I've been trying to learn how to use forms
now, I've gotten so far, what I want to be able to do is

load up form.php
input data there and have it send it' to it's self, and then show me another page with all my information I've just inputted,

now how do I tell PHP not to show me the bottom variables till i've subbmited the page?
I found some reffrence to $PHP_SELF
but it just told me to use it,. but didnt say how, any help would be greatly appreciated

Thanks
Trigger

Rahly
Bipolar (III) Inmate

From: Michigan
Insane since: Jul 2002

posted posted 12-22-2002 22:55

just check for those variables that your looking for.... if they are not there or not completely... then show the main page... else show the page with the variables...... easy as pie.

Rahly

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 12-22-2002 23:41

Here's what I do when I use a one page PHP cgi.

In my form you have your submit button. something like
<input type="submit" name="action" value="submit">

Then in your php you put an if statement

if ($HTTP_POST_VARS['action'] == "submit") {
// then print out all your variables.
} else {
// print out your form
}



.:[ Never resist a perfect moment ]:.

Trigger
Paranoid (IV) Inmate

From:
Insane since: Jun 2002

posted posted 12-23-2002 09:44

Cheers I'll go give that a go

Thanks
Trigger

Trigger
Paranoid (IV) Inmate

From:
Insane since: Jun 2002

posted posted 12-23-2002 11:50

ok here's my code

quote:
<?
$form = "<html>
<head></title>Form</title></head><body>
<form action='1.php' method='post'>
<P>Subject <br> :<input type='text' name='subject' width='200' align=right>
<br>Email Address<br> :<input type='text' name='address' width='200' align=right>
<br>Message <br> :<textarea name='body' rows='10' cols='30' align='right'>Your Message</textarea>
<br>
<input type='submit' name='action' value='submit'>
<br>
<br>
</form>
<body>
</html>";


$thankyou = "<h2>Thank you</h2>
your message $subject from $address has been subbmiteed";

$subject = $_POST['subject'];
$address = $_POST['addtess'];
$body = $_POST['body'];


if ($_POST['action'] == "submit")
{
$mode = "$thankyou";
}else{
$mode = "$form";
}

$print = $mode;
?>



now Im realy at a lose end as to whats wrong with this, I havent got a clue i've stared at it for the last half an hour and dont have a clue , can some one please hep?

OlssonE
Maniac (V) Inmate

From:  Eagleshieldsbay, Sweden
Insane since: Nov 2001

posted posted 12-23-2002 16:01

Replace this $print = $mode;

code:
echo $mode;



[This message has been edited by OlssonE (edited 12-23-2002).]

Trigger
Paranoid (IV) Inmate

From:
Insane since: Jun 2002

posted posted 12-23-2002 16:09

actulay the problem is.. I put

code:
$print   $mode;


instead of

print $mode;



OlssonE
Maniac (V) Inmate

From:  Eagleshieldsbay, Sweden
Insane since: Nov 2001

posted posted 12-23-2002 16:13

ya, but echo and print does the same thing!

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 12-23-2002 19:39

ya, but you didn't help him, since the problem was the additional $, not the print...

Trigger
Paranoid (IV) Inmate

From:
Insane since: Jun 2002

posted posted 12-23-2002 22:13

now Olsonon you can now rectify your unhelp full ness

by telling me whats wrong with this http://www.the-bronze.net/trig/bob.txt


I've tried to implemnt a function that validates the code, but I dont know im confusing my self now.. really confusing my self. my sense of logics gone and im being dealt error and after error
got any idea whats wrong with the script now?



OlssonE
Maniac (V) Inmate

From:  Eagleshieldsbay, Sweden
Insane since: Nov 2001

posted posted 12-23-2002 23:57

I would suggest that you rewrite it. I have fixed somethings but it still doesn't work.
look at some aviable formscripts and try to learn the structure...

TP: Merry Christmas and a Happy $new = $Year...

code:
<?


$subject = $_POST['subject'];
$address = $_POST['address'];
$body = $_POST['body'];



function check()
{

if(empty($subject)) $code = "<font color='red'>You must enter a Subject</font>";

elseif (empty($address)) $code = "<font color='red'>You must enter a Email adress</font>";

elseif (empty($body)) $code = "<font color='red'>You cant send a blank message</font>";

else $code = "Your message have been sent!";

}





$form = "<html>
<head></title>Form</title></head><body>
".$code."
<form action='<?=PHP_SELF?>' method='post'>
<P>Subject <br> :<input type='text' name='subject' width='200' align=right>
<br>Email Address<br> :<input type='text' name='address' width='200' align=right>
<br>Message <br> :<input tyoe=text name='body' rows='10' cols='30' align='right'>
<br>
<input type='submit' name='action' value='submit'>
<br>
<br>
</form>
<body>
</html>";

if ($_POST['action'] == "submit")
{
check();
$mode = $form;
}

else
{
$mode = $form;
}

echo $mode; // echo it is!


?>



[This message has been edited by OlssonE (edited 12-24-2002).]

« BackwardsOnwards »

Show Forum Drop Down Menu