473,396 Members | 1,734 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,396 software developers and data experts.

Form to append text to end of choice of URL's

Dan
Hi all-
I am trying to create a simple webpage to save me some time. The
general idea is create a form where I can type in the ticker symbol of
a company (ex: MSFT) and then select a bunch of different sites from
buttons or links to financial sites such as Yahoo Finance, BigCharts,
Routers, etc. Each of those financial sites has a different format for
their URLs such as
http://bigcharts.marketwatch.com/int....asp?symb=MSFT.
What I want to do is take all of these different URLs and just have it
add whatever symbol I choose at the end of them.

I am running into a few problems though. I can create a form to submit
to one site, but I do not know how to have a dozen or so links all use
the input from one text field. Also, I do not now how to code the part
to append the text to the end either. I can pass a variable but it
always includes the "?" which I don't want.

If anyone can provide any help or places to get started I would really
appreciate it! Thank you,
-Dan

Aug 14 '06 #1
6 2701
$sites = array(
'marketwatch' =>
'http://bigcharts.marketwatch.com/intchart/frames/frames.asp?symb=%s',
'someothersite' ='http://www.blah.com/?ticker=%s&something=foo',
);

// loop through the sites
foreach ( $sites as $url )
{
echo sprintf($url,$_GET['symbol']); // replaces %s with your symbol
}

Aug 14 '06 #2
Dan
I'm sorry I am trying to figure this out and I need a little more help.
I am fairly new to this and while I understand the logic I am not sure
exactly where to place this. Can I just use a regular form? If so, do
I have a separate submit button for each site I want to use? Thanks
again for your help,
-Dan
BKDotCom wrote:
$sites = array(
'marketwatch' =>
'http://bigcharts.marketwatch.com/intchart/frames/frames.asp?symb=%s',
'someothersite' ='http://www.blah.com/?ticker=%s&something=foo',
);

// loop through the sites
foreach ( $sites as $url )
{
echo sprintf($url,$_GET['symbol']); // replaces %s with your symbol
}
Aug 14 '06 #3
reading your post again I see you don't want the "?" in your urls.
That's a result of using the "get" method with your form (the default)
here's a more complete code for your page:

<?php

$sites = array(
'marketwatch' =>
'http://bigcharts.marketwatch.com/intchart/frames/frames.asp?symb=%s',
'someothersite' ='http://www.blah.com/?ticker=%s&something=foo',
);

if ( !isset($_POST['symbol']) )
$_POST['symbol'] = '';

?>

<FORM method="POST">
<INPUT type="text" name="symbol" value="<?php echo
htmlspecialchars($_POST['symbol']); ?>" />
</FORM>

<?php
if ( !empty($_POST['symbol']) )
{
// loop through the sites
foreach ( $sites as $name =$url )
{
$url = sprintf($url,urlencode($_GET['symbol'])); // replaces %s with
your symbol
echo '<A HREF="'.$url.'">'.$name.'</A><BR />';
}
}
?>

Aug 14 '06 #4
Dan
That seems to be what I want to do except that the symbol is not being
replaced. I just get an empty end of line
(http://bigcharts.marketwatch.com/int...ames.asp?symb=)


BKDotCom wrote:
reading your post again I see you don't want the "?" in your urls.
That's a result of using the "get" method with your form (the default)
here's a more complete code for your page:

<?php

$sites = array(
'marketwatch' =>
'http://bigcharts.marketwatch.com/intchart/frames/frames.asp?symb=%s',
'someothersite' ='http://www.blah.com/?ticker=%s&something=foo',
);

if ( !isset($_POST['symbol']) )
$_POST['symbol'] = '';

?>

<FORM method="POST">
<INPUT type="text" name="symbol" value="<?php echo
htmlspecialchars($_POST['symbol']); ?>" />
</FORM>

<?php
if ( !empty($_POST['symbol']) )
{
// loop through the sites
foreach ( $sites as $name =$url )
{
$url = sprintf($url,urlencode($_GET['symbol'])); // replaces %s with
your symbol
echo '<A HREF="'.$url.'">'.$name.'</A><BR />';
}
}
?>
Aug 14 '06 #5
"typo"
I didn't change the $_GET['symbol'] from my frist post to
$_POST['symbol']
make the change and all is well

Dan wrote:
That seems to be what I want to do except that the symbol is not being
replaced. I just get an empty end of line
(http://bigcharts.marketwatch.com/int...ames.asp?symb=)


BKDotCom wrote:
reading your post again I see you don't want the "?" in your urls.
That's a result of using the "get" method with your form (the default)
here's a more complete code for your page:

<?php

$sites = array(
'marketwatch' =>
'http://bigcharts.marketwatch.com/intchart/frames/frames.asp?symb=%s',
'someothersite' ='http://www.blah.com/?ticker=%s&something=foo',
);

if ( !isset($_POST['symbol']) )
$_POST['symbol'] = '';

?>

<FORM method="POST">
<INPUT type="text" name="symbol" value="<?php echo
htmlspecialchars($_POST['symbol']); ?>" />
</FORM>

<?php
if ( !empty($_POST['symbol']) )
{
// loop through the sites
foreach ( $sites as $name =$url )
{
$url = sprintf($url,urlencode($_GET['symbol'])); // replaces %s with
your symbol
echo '<A HREF="'.$url.'">'.$name.'</A><BR />';
}
}
?>
Aug 14 '06 #6
Dan
I just figured that out as well. Thanks for all your help!
-Dan
BKDotCom wrote:
"typo"
I didn't change the $_GET['symbol'] from my frist post to
$_POST['symbol']
make the change and all is well

Dan wrote:
That seems to be what I want to do except that the symbol is not being
replaced. I just get an empty end of line
(http://bigcharts.marketwatch.com/int...ames.asp?symb=)


BKDotCom wrote:
reading your post again I see you don't want the "?" in your urls.
That's a result of using the "get" method with your form (the default)
here's a more complete code for your page:
>
<?php
>
$sites = array(
'marketwatch' =>
'http://bigcharts.marketwatch.com/intchart/frames/frames.asp?symb=%s',
'someothersite' ='http://www.blah.com/?ticker=%s&something=foo',
);
>
if ( !isset($_POST['symbol']) )
$_POST['symbol'] = '';
>
?>
>
<FORM method="POST">
<INPUT type="text" name="symbol" value="<?php echo
htmlspecialchars($_POST['symbol']); ?>" />
</FORM>
>
<?php
if ( !empty($_POST['symbol']) )
{
// loop through the sites
foreach ( $sites as $name =$url )
{
$url = sprintf($url,urlencode($_GET['symbol'])); // replaces %s with
your symbol
echo '<A HREF="'.$url.'">'.$name.'</A><BR />';
}
}
?>
Aug 14 '06 #7

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

Similar topics

9
by: Tom | last post by:
I have created the following code for a product select/payment form (don't know if there is a better way) and I have been trying to make the following changes (unsuccessfully so far): 1) ...
13
by: MLH | last post by:
I have a form with two controls: !! - combo box !! - text box A button on the form tries to run this SQL when clicked... INSERT INTO BodyMsgsSent (ToWhom, BodyText) SELECT DISTINCTROW !! AS...
3
by: Chris | last post by:
Hi, I'm trying to append text from another class to a generic richTextBox that I've added to a Windows form. I can't seem to figure out how to expose the richTextBox to append text to it. ...
1
by: GlobalDeveloper | last post by:
The following simple code which is supposed to enumerate the form and query variables does work in IE6 and FireFox but NOT in IE5. Could anyone advice me on this one??? I think the issue has to...
7
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem...
14
by: Professor Yonce | last post by:
I have made form for E-Mail. I have entered code but the Import system does not work. It has squiggly line underneath it showing it is not communicating. It Will not build. Public Class...
10
by: pythonnoob | last post by:
Hello everyone. New to python as well as this forum, but i must say ive learned a but already reading through some posts. Seems to be a pretty helpful community here. Before i post a question...
3
by: ibeehbk | last post by:
Hi. I have a form made in xhtml. I test via vbscript to make sure none of the fields are empty and properly formatted (ie email). All the regular fields work. However, I have two drop down menus...
1
omerbutt
by: omerbutt | last post by:
hi i am making a intranet online test application for a school and for that i have to make a form for creating the test the logic is to select a subject and then the number of questions for that test...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
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,...

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.