/    Sign up×
Community /Pin to ProfileBookmark

Post from a script

Let me break it down my situation for you.

I have about 400 lines of code verifiying this registration form with about 50 $_POST[] variables.

The way my code works is if there is a POST that fails verification it will set two variables here is an example

[code=php]
if($variable == “”)
{
$user_err .= “<span style=”color:red;”>You must enter a Zip code.</span><br />”;
$send = “no”;
}
if($variable2 == “”)
{
$user_err .= “<span style=”color:red;”>You must enter a Name </span><br />”;
$send = “no”;
}
[/code]

There is an conditional that checks $send and if it equals “no” then it will print $user_err that can hold multiple errors, back to the user. If send == “” then it will send info to the designated tables and send them a verifaction e-mail.

Here is my problem…
If send == “no” then I need to modify headers and send them to a template page. this template page must recieve a POST variable holding all the errors so they can see what they need to fill out to be successfully registered. I have thought about putting all the errors in a session variable but I don’t want to write anything to the servers hard disk, and a GET would be just crazy and probably immpossible if the URL string is too long.

So all in all How Do I…

SET a POST Variable and then POST it to the page while in a script? (no form).

I know what your thinking but I really want to keep this script free of includes and html. Thanks for your help

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@jignesh1Nov 21.2006 — can u foreach all the variable in hidden field

after u have headersent to the next page

that way u could have ur template page looking for ur hidden field

im not sure but u could atlease try
Copy linkTweet thisAlerts:
@NogDogNov 21.2006 — You'd probably either have to use the [url=http://www.php.net/curl]cURL functions[/url] and/or the [url=http://www.php.net/http]HTTP extension[/url].
Copy linkTweet thisAlerts:
@Markbad311authorNov 21.2006 — That is possible but remember I need to get that variable to the template page. If I don't use a post variable and send it to the template page then that variable it is looking for isn't there.

like this

First Script
[code=php]
//Set Post Variable
$_POST['error'] = $user_err;

//modify headers
header("Location: http://www.domain.com/template.php");
exit;

[/code]


Template File
[code=php]
//print error
print $_POST['error'];
[/code]


now I can modify headers till I am blue in the face but that variable won't post to the template.php file. And in the template.php file It will say "undefined index $_POST['error']" or something like that.
Copy linkTweet thisAlerts:
@Markbad311authorNov 21.2006 — hmm the cURL library never thought of that, Thanks NogDog
Copy linkTweet thisAlerts:
@sb_Nov 21.2006 — I would use Javascript instead to do this initially. Having a second check in your code is always a good idea however.
×

Success!

Help @Markbad311 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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