July 28th, 2000, 09:48 AM
-
I am having a break down in the "how to turn the page process.
If a html form has the action attribute set to itself when the form is sumitted it validates (or not) then how does one get to the next page.
I have a hidden variable - $validated but am a loss where to go with it.
My code so far is based on a really sorry book "Professional PHP Programming" and it glosses over or simply dismisses big fundamentals. The book is written for someone that already knos and loves the language.
July 28th, 2000, 10:17 AM
-
Actually that is a good book you have. You might try reading it all the way through. There are plenty of examples to show you how to do what you are referring to.
example:
<?php
switch ($form) :
case "validate" :
if ($accept == 1) {
echo "Thank you, visit <a href="www.someurl.com">Our Sponsor</a>n";
} else {
echo "Sorry you don't agee.<br>n";
}
default :
echo "<form action="$PHP_SELF" method=post>n";
echo "<select name=accept><option value="1">Agree <option value="2">Disagree</select>n";
echo "</form>n";
endswitch;
?>
July 28th, 2000, 10:21 AM
-
you may want to put some javascript to it. ok, say this is a part of the script which validates your form and send it's information to another file..
...
//validation goes here
if(whatever condition) {
$validated = 1;
echo '
<html><title></title><head>
<script>
function sendthis(****) {
****.submit();
}
</script>
</head><body onLoad="sendthis(document.damnform);">
<form action="somewhere" name="damnform">
<input type="hidden" name="something" value="idduno">
...
';
}
note the <body> part and the script. the onLoad will ensure you that this form will automatically submit itself when loaded; of course, you may want to put some validification function before the html, that's why i putted some simple conditional function..
July 28th, 2000, 11:50 AM
-
The book misses a decent table of contents, lame index pages and no glossary which you will see when you attempt to use it as a text book. however, I digress
I'm not having a problem embedding an anchor I' having a problem redirecting the form to another url under software control. At first glance the REFERENCE:HEADER would work eg:
if ($validated) {
Header("Location: <A HREF="http://www.domain.com/member.html");" TARGET=_blank>http://www.domain.com/member.html");</A>
}
else {
Header("Location: <A HREF="http://www.domain.com/login.html");" TARGET=_blank>http://www.domain.com/login.html");</A>
}
but no joy there either.
Still stuck checking out (horror) the java app below.
be a good time to have an idea
Bill
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by ray_cormier:
Actually that is a good book you have. You might try reading it all the way through. There are plenty of examples to show you how to do what you are referring to.
example:
<?php
switch ($form) :
case "validate" :
if ($accept == 1) {
echo "Thank you, visit <a href="www.someurl.com">Our Sponsor</a>n";
} else {
echo "Sorry you don't agee.<br>n";
}
default :
echo "<form action="$PHP_SELF" method=post>n";
echo "<select name=accept><option value="1">Agree <option value="2">Disagree</select>n";
echo "</form>n";
endswitch;
?>[/quote]
July 28th, 2000, 12:54 PM
-
Why don't you tell us what happens when your script hits the header("Location ..)??
Maybe then we can help you.
July 28th, 2000, 01:17 PM
-
I am trying every combination of the following, with out success.
The manual insists that there be no output prior to the below: Noticee the example dosen't have script tags (eg <?php ?> ) around it but I have tried every posible combination of the line:
Header ("Location://www.domain.com/member.html");
and no joy - thought that I had discovered a new route to nirvana when I found the following fragment - but no... Just another whirlpool of false hope in a sea of dispair.
Bill
if ($validated) {
Header("Location: <A HREF="http://www.domain.com/member.html");" TARGET=_blank>http://www.domain.com/member.html");</A>
}
else {
Header("Location: <A HREF="http://www.domain.com/login.html");" TARGET=_blank>http://www.domain.com/login.html");</A>
}
This is from
http://www.php.net/manual/html/function.header.html for more info.
July 28th, 2000, 02:14 PM
-
I don't know how else to but this: post your entire script thru the header() statements and tell us EXACTLY what happens. All you are telling us is "no joy" that isn't enough information to help you.
July 28th, 2000, 03:23 PM
-
Good news, joy in mudville
Got the header to play with the following:
<?PHP
$rs = 0;
if ($rs == 0) {
header("Location:http://www.mydomain.com/memberservices.php3");
exit;
}
if ($rs == 1) {
header("Location: <A HREF="http://www.mydomain.com/Quiz/members.htm");" TARGET=_blank>http://www.mydomain.com/Quiz/members.htm");</A>
}
else{
header("Location: <A HREF="http://www.mydomain.com/Quiz/index.htm");" TARGET=_blank>http://www.mydomain.com/Quiz/index.htm");</A>
}
?>