473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

return to html

Trying to write html form program that calls php prog. If php prog has
problem with what was entered would like to return from php to html program.

Is this possible and if so, how?

TIA
Jun 6 '07 #1
8 2360
zoilus wrote:
Trying to write html form program that calls php prog. If php prog has
problem with what was entered would like to return from php to html
program.

Is this possible and if so, how?

TIA
Hi,

Plain html pages are not refered to as programs, just html files.
Unless the Javascript in them is worth calling a program. ;-)

What you need is something like this:
<?php
// just an example, we expect a formelement named firstname
// If not set, redirect to error.html
if (!isset($_POST["firstname"])){
// refuse
header("Location: http://www.example.com/error.html");
exit;
}

// do your normal processing here.

?>
Regards,
Erwin Moller
Jun 6 '07 #2
Erwin,

Thanks for the post. Maybe you could help me with this code. The code is
not transfering to variables to the search.php program.

<html>
<head>
<title>testing downloaded query form</title>
</head>
<body>
<h2>Search</h2>
<!-- <form name="search" method="post" action="<?=$PHP_SELF?>" -->
<form name="search" method="post" action="search.php">
Seach for: <input type="text" name="find" /in
<Select NAME="field">
<Option VALUE="fname">First Name</option>
<Option VALUE="lname">Last Name</option>
<Option VALUE="info">Profile</option>
</Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" />
</form>

</body>
</html>

none of the variable are set in search.php

Erwin Moller wrote:
zoilus wrote:

>>Trying to write html form program that calls php prog. If php prog has
problem with what was entered would like to return from php to html
program.

Is this possible and if so, how?

TIA


Hi,

Plain html pages are not refered to as programs, just html files.
Unless the Javascript in them is worth calling a program. ;-)

What you need is something like this:
<?php
// just an example, we expect a formelement named firstname
// If not set, redirect to error.html
if (!isset($_POST["firstname"])){
// refuse
header("Location: http://www.example.com/error.html");
exit;
}

// do your normal processing here.

?>
Regards,
Erwin Moller
Jun 6 '07 #3
zoilus wrote:
none of the variable are set in search.php
How are you accesing the variables there?

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

http://acm.asoc.fi.upm.es/~mr/ ; http://acm.asoc.fi.upm.es/~ivan/
MSN:i_*************************@hotmail.com
Jabber:iv*********@jabber.org ; iv*********@kdetalk.net
Jun 6 '07 #4
print "You have entered search.php<br>";
/*
//This is only displayed if they have submitted the form
print "<br>variable fname, lname and info is: $fname, $lname, $info <br>";
print "<br>variable searching is: $searching";
print "<br>variable search is: $search";
print "<br>variable find is: $find";
*/
// print_r(debug_backtrace()); //got from web, does not seem to work.

if (!isset($_POST["fname"])){
print "fname is not set";
}

if ($searching =="yes")
{
echo "<h2>Results</h2><p>";
}

//If they did not enter a search term we give them an error
if ($find == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
Iván Sánchez Ortega wrote:
zoilus wrote:

>>none of the variable are set in search.php


How are you accesing the variables there?
Jun 6 '07 #5
zoilus wrote:
print "You have entered search.php<br>";
/*
//This is only displayed if they have submitted the form
print "<br>variable fname, lname and info is: $fname, $lname, $info <br>";
print "<br>variable searching is: $searching";
print "<br>variable search is: $search";
print "<br>variable find is: $find";
*/
// print_r(debug_backtrace()); //got from web, does not seem to work.

if (!isset($_POST["fname"])){
print "fname is not set";
}

if ($searching =="yes")
Stop here.

I think you are relying on old (bad) PHP examples that use register_globals.
$searching is empty in your example.

Use: $_POST["searching"] instead.
That contains the the value of the formelement named "searching".
(They are case sensitive.)

Regards,
Erwin Moller

{
echo "<h2>Results</h2><p>";
}

//If they did not enter a search term we give them an error
if ($find == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
Iván Sánchez Ortega wrote:
>zoilus wrote:

>>>none of the variable are set in search.php


How are you accesing the variables there?
Jun 6 '07 #6
Message-ID: <Ey*******************@bgtnsc05-news.ops.worldnet.att.net>
from zoilus contained the following:
>Trying to write html form program that calls php prog. If php prog has
problem with what was entered would like to return from php to html program.

Is this possible and if so, how?
The back button works.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jun 6 '07 #7
Rik
On Wed, 06 Jun 2007 19:23:45 +0200, Geoff Berrow <bl******@ckdog.co.uk>
wrote:
Message-ID: <Ey*******************@bgtnsc05-news.ops.worldnet.att.net>
from zoilus contained the following:
>Trying to write html form program that calls php prog. If php prog has
problem with what was entered would like to return from php to html
program.

Is this possible and if so, how?

The back button works.
But users aren't to be trusted to know that a back button exists :P
--
Rik Wasmus
Jun 6 '07 #8
My mistake. The copied program was severly lacking. Have made all
patches. Search program had no POST statements amoung other things.

Thanks to all

zoilus wrote:
print "You have entered search.php<br>";
/*
//This is only displayed if they have submitted the form
print "<br>variable fname, lname and info is: $fname, $lname, $info <br>";
print "<br>variable searching is: $searching";
print "<br>variable search is: $search";
print "<br>variable find is: $find";
*/
// print_r(debug_backtrace()); //got from web, does not seem to work.

if (!isset($_POST["fname"])){
print "fname is not set";
}

if ($searching =="yes")
{
echo "<h2>Results</h2><p>";
}

//If they did not enter a search term we give them an error
if ($find == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
Iván Sánchez Ortega wrote:
>zoilus wrote:

>>none of the variable are set in search.php

How are you accesing the variables there?
Jun 6 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Don | last post by:
I want the server-side php script to return a browser page that is essentially a copy of the original client page that contained the <form> which referenced the php script in the first place....
5
by: Lee | last post by:
I am using a modal window and an iFrame to try and pull a return value back. I am doing this across domains. I have the value returned from the modal window to the iFrame window but I can not...
5
by: w i l l | last post by:
Why does this work the way it does? If someone could explain return true, and return false to me I'd greatly appreciate it. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> ...
7
by: sindre | last post by:
Hi, Some place I use links to submit forms instead of a submit button. The way I have done this is: <a href="javascript:document.getElementById('<?php print "delete$i"...
1
by: Piotr | last post by:
I have popup window (window.open) where I put any value in input field. After submit I wan to to return to the main window and get value from popup window. How to close popup window and return to...
24
by: sureshjayaram | last post by:
In some functions where i need to return multiple error codes at multiple places, I use multiple return statements. Say for ex. if (Found == 1) { if (val == -1) return error1; } else { if...
2
by: thuythu | last post by:
Please help me.... I used and Javascript to view the data. But when i click button open a popup windows, then select data and click save button. The popup close and return the main page, but the...
1
by: Sudarhan | last post by:
Hello frnds I have created a webbased form using asp and javascript .. while submitting the form i am validating the fields in the form .it validates the field and returns alert message. but when...
12
by: Justn226 | last post by:
anyone have any idea why i am not getting any return values? it will return the words just not the numbers? HTML <HTML> <head> <title>Zellers Carpeting Cost Estimate</title> </head> ...
5
by: iGuff | last post by:
I have this sample page that I made, and it works fine in FF and Safari. But does not work in IE (all versions). I am currently using IE8, but it did not work on IE7 either. However, it used to work...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.