473,657 Members | 2,358 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to process text from HTML form?

This may be a basic question -

I have a form on my web page that looks like this:

<span id="site_search ">
<form name="frmSearch " method="post" action="" style=" margin: 0 0 0
15px ">
Search This Site:
<input type="text" name="search_fi eld"><input name="Go" type="submit"
value="Go" style="font-family:Arial, Helvetica, sans-serif">
</form>
</span><br/>

How do take the input from this form and use it to populate another form (on
another page within the same site) when the user clicks the Go button?
Also, how do I cancel any action if the form is empty?

Thanks in advance.
Jul 17 '05 #1
17 3082
deko wrote:
This may be a basic question -

I have a form on my web page that looks like this:

<span id="site_search ">
<form name="frmSearch " method="post" action="" style=" margin: 0 0 0
15px ">
Search This Site:
<input type="text" name="search_fi eld"><input name="Go" type="submit"
value="Go" style="font-family:Arial, Helvetica, sans-serif">
</form>
</span><br/>

How do take the input from this form and use it to populate another form (on
another page within the same site) when the user clicks the Go button?
Also, how do I cancel any action if the form is empty?

Thanks in advance.


The input from user can be found in eiher $_GET or $_POST arrays
depending on the method your form uses. You should read
http://www.php.net/manual/en/languag...predefined.php

In you case you can use something like this:
if (empty($_POST['search_field'])) {
// Error message
} else {
// Search code
}
Jul 17 '05 #2
I noticed that Message-ID: <cd**********@p laza.suomi.net> from eXeonical
contained the following:
The input from user can be found in eiher $_GET or $_POST arrays
depending on the method your form uses. You should read
http://www.php.net/manual/en/languag...predefined.php

In you case you can use something like this:
if (empty($_POST['search_field'])) {
// Error message
} else {
// Search code
}


And you populate a text box like this

<input type="text" name="name"valu e="<?php echo $_POST['search_field'];
?>">
--
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/
Jul 17 '05 #3
.oO(deko)
I have a form on my web page that looks like this:

<span id="site_search ">
<form name="frmSearch " method="post" [...]


span is an inline-element, you can't put block-elements like a form in
it. Use a div or a more reasonable element instead.

Micha
Jul 17 '05 #4
"Geoff Berrow" <bl******@ckdog .co.uk> wrote in message
news:v7******** *************** *********@4ax.c om...
I noticed that Message-ID: <cd**********@p laza.suomi.net> from eXeonical
contained the following:
The input from user can be found in eiher $_GET or $_POST arrays
depending on the method your form uses. You should read
http://www.php.net/manual/en/languag...predefined.php

In you case you can use something like this:
if (empty($_POST['search_field'])) {
// Error message
} else {
// Search code
}


And you populate a text box like this

<input type="text" name="name"valu e="<?php echo $_POST['search_field'];
?>">
--
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/


Don't forget to escape HTML special characters. Hence

<input type="text" name="name"valu e="<?php echo
htmlspecialchar s($_POST['search_field']); ?>">
Jul 17 '05 #5
> span is an inline-element, you can't put block-elements like a form in
it. Use a div or a more reasonable element instead.


Thanks for the tip.
Jul 17 '05 #6
> And you populate a text box like this

<input type="text" name="name"valu e="<?php echo $_POST['search_field'];
?>">


Hi and thanks for the reply.

So, the receiving form should look like this:

<INPUT TYPE=text value="<?php echo $_POST['search_field'];?>">
<INPUT type=submit VALUE='Search'>

But the receiving form is on a different page - how do I pass the value of
$_POST to this other page? The idea is for the user to click Go on one page
and then be taken to another page with another form which will be
automatically populated with $_POST from the first page/form.

I tried this on the sending form/page:

<div id="site_search ">
<form name="frmSearch " method="post" action="" style=" margin: 0 0 0
15px ">
Search This Site:
<input type="text" name="search_fi eld"><input name="Go" type="submit"
value="Go" style= "font-family:Arial, Helvetica, sans-serif">
</form>
<?php echo ($_POST['search_field']);?>
<meta http-equiv="refresh" "csi_search.php "> <!-- Here I want to
redirect to csi_search.php where the receiving form is. -->
</div><br/>

The value I entered in the form was echoed on the sending page, but I didn't
get redirected to csi_search.php. Suggestions?
Jul 17 '05 #7
I noticed that Message-ID: <qP************ ********@comcas t.com> from
Chung Leong contained the following:
Don't forget to escape HTML special characters. Hence

<input type="text" name="name"valu e="<?php echo
htmlspecialcha rs($_POST['search_field']); ?>">


Nah, that's the wrong place for it. Besides, he may want to preserve
markup.

He might want to use stripslashes($_ POST['search_field']) though

--
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/
Jul 17 '05 #8
I noticed that Message-ID:
<55************ ****@newssvr21. news.prodigy.co m> from deko contained the
following:
But the receiving form is on a different page - how do I pass the value of
$_POST to this other page?


<form name="frmSearch " method="post" action="other_p age.php">

--
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/
Jul 17 '05 #9
> <form name="frmSearch " method="post" action="other_p age.php">

I'll give it a shot....

Regarding cancelling action if a form is blank, I'm trying to get this to
work:

<form method="POST" action=
"<?
if ( empty($_POST['message']) || empty($_POST['email_address']) )
{
} //by the way, is there a better way to construct this without the else
statement?
else
{
include "send_mail.php" ;
}
?>"
style="font-family: Arial, Helvetica, sans-serif; font-size:12px">
Email address: <input name="email_add ress" type="text" /><br />
Message:<br />
<textarea name="message" rows="12" cols="25"></textarea><br />
<input type="submit" value="Send" style="font-family: Arial, Helvetica,
sans-serif">
</form>

The problem is that get errors the second time I try ti use the form - but
it seems to work the first around. The error I get is something like:

Warning</b>:%20%20Cannot %20modify%20hea der%20informati on%20-%20headers%20al r
eady%20sent%20b y%20(output%20s tarted%20at%20/home/clearpoi/public_html/beta/
contact.php:19) %20in%20<b

My guess is that I need to reset the form after processing it. Should I
have some kind of reset action in send_mail.php? Below is the script. As
you will see, I am trying to send the user to a thank you page after
submitting feedback. This seems to be buttering things up somehow...

<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
mail( "da**@Clearpoin tSystems.com", "CSI Feedback Form", $message, "From:
$email_address" );
header( "Location: http://www.ClearpointS ystems.com/beta/thankyou.html" );
?>
Jul 17 '05 #10

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

Similar topics

1
27484
by: Sean | last post by:
I can connect to a machine remotely with no problems but I'm having trouble trying to create a process remotely. Initially this was a perl and VB script which I'm converting to python. Its entire purpose is to start a process remotely. The problem initially was that the perl script could not 'see' any mapped drives as it would alway return 'access denied' so I'm trying to not only rewrite the script but fix this problem and my idea was...
4
9195
by: John | last post by:
I am trying to spawn a seperate process from my asp page so when a user clicks the link or button a desktop program is launched. This will be on an intranet and the program will exist on the users desktop. I can use the following code in webmatrix to run a process on my local machine: <%@ Page Language="VB" %> <script runat="server"> ' Insert page code here
2
4984
by: RL | last post by:
Hello Perl gurus, 1. I have a web page where I can push a button (dospawn.html). 2. This button calls a CGI script (spawnboss.cgi) 3. spawnboss.cgi calls a forking perl script (forkme.pl) 4. forkme.pl calls the process creation script (createme.pl) 5. createme.pl creates my notepad.exe process, but no window shows up on my PC. The result on my web browser is:
1
3679
by: Bartek | last post by:
Hello This is my problem: It consider xml 2 xml conversion. source document had unknown structure (xhtml), xslt must process every node, attribute, text, comments etc. from source and write in destination file. During that process i must catch some nodes (e.g. <input> position of this node in XML tree is unknown )and change the value attribute. The destination xml file must be the exact copy of source file + changes on
77
4571
by: Charles Law | last post by:
Hi guys I have a time critical process, running on a worker thread. By "time critical", I mean that certain parts of the process must be completed in a specific time frame. The time when the process starts is not especially important, but it must be complete within a small number of seconds. The operations I am performing do not take a long time (hundreds of milliseconds), but as each part of the process is complete, my worker thread...
10
6907
by: Kathy Burke | last post by:
HI. in asp.net app, I have an xmlDocument that I transform to the client html. Using xsl I create a few textboxes to capture user input. Each of these are related to <data> elements in the xmlDoc. I want to use the Forms collection to post the html form back to an asp.net page, and process each request.form object (textbox) via an xml node.value update. For any given xmlDocument there is an unknown number of items resulting in...
5
2071
by: Paul Bergson | last post by:
I have been trying to get a process to start up and run with arguments passed to it. I have gotten close (Thanks to help from this board) but I there is a failure while I'm running this because the c:\bin\xcacls starts nothing happens. How can I see output from the console i was trying to get the ProcessStartInfo.RedirectStandardOutput Property to work but even if I got the system to process it I didn;t know where the output was being...
2
4578
by: Carl Gilbert | last post by:
Hi I am trying to get an online gallery (www.ngallery.org - open source) to upload image to a folder. At the moment I am using localhost but plan to move to some web space when I get it all working. I need to update my 'images' folder permissions so the ASP.NET worker process has write permissions. However, when I go to the folder permissions, there is not worker process
5
2327
by: mouac01 | last post by:
I'm new to PHP/Javascript. I have a simple form I want to validate the fields with javascript and then run the PHP script. All the scripts are in one page. I want PHP to control where the next page is. It works fine without the javascript but when I add the javascript the page doesn't do anything besides the validation. Thanks for your help... Chong ----login.html-------------------------------- <?php ob_start();
32
1686
by: John Wright | last post by:
I have a long process I run that needs to be complete before the user can continue. I can change the cursor to an hourglass, but I want to update the Status Strip on the bottom during the process. I set the statusstrip label to "Downloading...", but it will not show up on the form. I need to display this message before it starts the process. I can put a thread.sleep for 1 second after I do the initial process, but that seems sloppy to me. ...
0
8411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7351
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.