/    Sign up×
Community /Pin to ProfileBookmark

dreamweaver and forms

anyone out there got some advise for me regarding forms built in dreamweaver, i have built the form and was told to put “gdforms.php” (which is my hosting company)in the action box, but this isnt working,
I am new at this and am trying to teach myself, so if you know what to put in the action box for my form built in dreamweaver give me a shout ..thanks

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@jpmoriartyMar 08.2004 — the action box simply tells the form where to send the information. So if you put "gdforms.php" as the action, then it will either post or get the info in the form to gdforms.php, depending on whether you've set your method to post or get.

If you don't have the file gdforms.php then it will give you a 404 file not found error.

It shouldn't have anything to do with your hosting company. you need to design a page that will do something with the data that you've sent it.

eg
[code=php]
// page1.php
<html>
<head><title>page1</title>
</head>
<body>
<form name="form" action="page2.php" method="get">
Enter a number: <input type="text" name="number">
<input type="submit" value="Submit">
</form>
</body>
</html>

// page2.php
<html>
<head><title>page2</title>
</head>
<body>

<?php
echo "You entered the number ".$_GET['number']."!";
?>

</body>
</html>
[/code]

You'll notice that because you did method="get" the variable gets stuck on the end of the url in a "&number=..." fashion. if you post the data then it doesn't appear there. Does that help?
Copy linkTweet thisAlerts:
@bronwynauthorMar 08.2004 — much appreciated, here is my code so far for the action box is this right firstly?

<form action= "gdforms.php"?subject=informationrequest method="post" enctype="text/plain" name="information

but your saying i need to start a new page called gdforms.php and im a little confused what i need to write on that sorry, do i have to link it to the action box? sorry for not understanding that bit but as i said im trying to teach myself and i really appreciate your help ...thanks bronwyn
Copy linkTweet thisAlerts:
@jpmoriartyMar 08.2004 — no no no no no no no no no.

your action should be a name of a file. that's it -nothing else, just a file. like in my example. action="page2.php". no ?'s, no &'s, just the name of a file.

when you click on the submit button, it will send the data in your form to the page you've specified in the action box. so in my example, it sends whatever you type in the box to the page "page2.php".

now, because we used the method "get", it sends this data through the url. so the url, after you've clicked on submit, will be:

page2.php?number=****

where *
**
* is whatever you typed in the box.

in our code for the page2.php, we wrote it that it should output some text (in the echo) and also output the contents of the variable $_GET['number'] - which in this case will be ****. but whatever you want your site to do with the information you send in the form, you've got to program it to do it. so if you want it to output it like we did, then you program page2.php to output the data. if you want to add it to a database or some such, you've got to program the page to do that.

I would forget about what you're writing for the moment and use my example to figure out what's going on. It's only 2 pages of php to write (well, technically 1 page of php and 1 page of html), and it shouldnt be too hard to get your head around. failing that, just tell me what it is you're trying to achieve and i'll try and talk you through it.

And i would suggest getting a book too - php and my sql web development by luke welling and laura thompson is very good.
Copy linkTweet thisAlerts:
@bronwynauthorMar 08.2004 — im not sure how this is but when i first made the form this page appeared in my ftp le softwear and i deleted it as i wasnt sure what it was...after going back to my recycle bin this is what was in it ... to me it may as well be french as it looks very complicated,


<?php

$request_method = $_SERVER["REQUEST_METHOD"];

if($request_method == "GET"){

$query_vars = $_
GET;

} elseif ($request_method == "POST"){

$query_vars = $_POST;

}

reset($query_vars);

$t = date("U");

$fp = fopen("../data/gdform_
$t","w");

while (list ($key, $val) = each ($query_vars)) {

fputs($fp,"<GDFORM_VARIABLE NAME=$key START>n");

fputs($fp,"$valn");

fputs($fp,"<GDFORM_VARIABLE NAME=$key END>n");

if ($key == "redirect") { $landing_page = $val;}

}

fclose($fp);

if ($landing_page != ""){

header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");

} else {

header("Location: http://".$_
SERVER["HTTP_HOST"]."/");

}


?>
Copy linkTweet thisAlerts:
@bronwynauthorMar 08.2004 — i changed the action box code to this

<form action= "gdforms.php" method="post"" enctype="text/plain" name="information request" id="information request" "postgdform.php>


again im sorry i cant seem to grasp this right off it is great of you to walk me thru it and i say thanks again
Copy linkTweet thisAlerts:
@jpmoriartyMar 08.2004 — why can't you tell me what you want to achieve? i'd have thought it would speed up this process of me trying to guess what you want to do with other people's code.

but here we go:
[code=php]
<?php
$request_method = $_SERVER["REQUEST_METHOD"];
if($request_method == "GET"){
$query_vars = $_GET;
} elseif ($request_method == "POST"){
$query_vars = $_POST;
}
reset($query_vars);
[/code]

all this does is look to see how the data is being sent - is it GET or is it POST. it then sets $query_vars so that it can use it in the future.
[code=php]
<?php $t = date("U");
$fp = fopen("../data/gdform_$t","w");
[/code]

this sets $t to be the date in a special format, and then it creates a file ./data/gdform_[i]whatever the date was[/i] so that it can write to it.

[code=php]
<? while (list ($key, $val) = each ($query_vars)) {
fputs($fp,"<GDFORM_VARIABLE NAME=$key START>n");
fputs($fp,"$valn");
fputs($fp,"<GDFORM_VARIABLE NAME=$key END>n");
if ($key == "redirect") { $landing_page = $val;}
}
fclose($fp); [/code]

this cycles through all the fileds that came from the form that you filled in and writes code out to the file it created earlier. then it closes the file.
[code=php]<?
if ($landing_page != ""){
header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
} else {
header("Location: http://".$_SERVER["HTTP_HOST"]."/");
} [/code]

then it either sends you back to either the landing page, or alternatively the root of the directory.

the reason that you're finding it confusing is 'cos you're trying to do too much. You analogy with french is interesting - it'd be like saying "humm, i quite fancy trying to learn french. I know what I'll do - I'll pick up a french newspaper and see if i can understand it". It's pretty brave, but possibly not going to be the most efficient way of achieving it.
Copy linkTweet thisAlerts:
@bronwynauthorMar 08.2004 — yes you are right about the french, a photographer just doesnt seem to grasp the meaning of code, even though i have done a couple of courses and read books it does seem like i need much more instruction, what i am trying to do is send the data from a form to the script where they forward it on to a designated email with the information correlated. i thought it was a relatively simple thing but i see now its very complicated ..so i thank you again for your patients and i will study the info you gave me, hopefully work it out.

ps yes i am brave ...but draw the line at the impossible
Copy linkTweet thisAlerts:
@keyconJun 16.2009 — This is a great thread as I am trying to change the gdform.php file provided by GoDaddy to redirect the landing page to my Thank You page.

Where do I change the php code to tell the landing page to go to my thankyou.html page?
×

Success!

Help @bronwyn spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...