Closed Thread Icon

Topic awaiting preservation: HTML Form Control and PHP (Beginner) (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12633" title="Pages that link to Topic awaiting preservation: HTML Form Control and PHP (Beginner) (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: HTML Form Control and PHP (Beginner) <span class="small">(Page 1 of 1)</span>\

 
shattered
Obsessive-Compulsive (I) Inmate

From:
Insane since: Feb 2003

posted posted 03-04-2003 02:54

Hello,
I don't know where I should put this question, because it concerns PHP and HTML. I hope this the right place to post. I'm trying to create a HTML form page so that when the information is submitted, a new page in PHP would display whatever was filled in the fields. The problem is that, whatever is filled in in the HTML forms fields do not show up in the PHP page .
Here is the code for HTML, anmed "song_info.html":

quote:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<FORM METHOD=GET ACTION="song_info.php">
<p>Please enter song information here:</p>
<table width="65%" border="1">
<tr>
<td width="27%">Title</td>
<td width="73%"><form name="form2" method="post" action="">
<input name="title" type="text" size="60">
</form></td>
</tr>
<tr>
<td>Artiste</td>
<td><form name="form3" method="post" action="">
<input name="artiste" type="text" size="60">
</form></td>
</tr>
<tr>
<td>Genre</td>
<td><form name="form4" method="post" action="">
<input name="genre" type="text" size="60">
</form></td>
</tr>
<tr>
<td>Length</td>
<td><form name="form5" method="post" action="">
<input name="length" type="text" size="60">
</form></td>
</tr>
<tr>
<td>Song path</td>
<td><form name="form6" method="post" action="">
<input name="path" type="text" size="60">
</form></td>
</tr>
</table>
<form action="http://www.radio.deltapath.com/song_info.php" method="post" enctype="application/x-www-form-urlencoded"
name="form1" target="_self">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Clear Field">
</form>
<p>  </p>
</body>
</html>



And this is my PHP codes, named "song_info.php":

quote:
<HTML>
<HEAD></HEAD>
<BODY>
Song information:
<BR>
Title:
<?php
echo $title;
?>
<BR>
Artiste:
<?
echo $artiste;
?>
<BR>
Genre:
<?
echo $genre;
?>
<BR>
Length:
<?
echo $length;
?>
<BR>
Song Path:
<?
echo $path;
?>

</BODY>
</HTML>



Thanks for helping!

[This message has been edited by shattered (edited 03-04-2003).]

[This message has been edited by shattered (edited 03-04-2003).]

Kriek
Maniac (V) Inmate

From: Florida
Insane since: Jul 2001

posted posted 03-04-2003 04:52

Use $_POST and $_GET (Predefined Variables). If you are running PHP version 4.0.6 or lower, you will need to use $HTTP_XXX_VARS instead as these versions do not have superglobals =) If you are looking for practical examples check this tutorial out (Dealing with Forms) or look this up in the manual (Variables from outside PHP) Hope this helps.

__________________

Kriek says '[SYSTEMWIDE_MESSAGE] PHP Meetup'
What we do is never understood; only praised and blamed

[This message has been edited by Kriek (edited 03-04-2003).]

trib
Paranoid (IV) Inmate

From: Den Haag, Netherlands
Insane since: Sep 2002

posted posted 03-04-2003 07:32

As a catchall, I tend to use the superglobal $_REQUEST - it's an associative array which holds all the variables in $_GET, $_POST, and $_COOKIE - I'm just lazy - I like 'em all in one place. (Same documentation refs as given by Kriek). Example ....

code:
$username=trim($_REQUEST["username"]);
$email=trim($_REQUEST["email"]);


If you're using < 4.1 (and if it's your server) then check the state of the register_globals directive in php.ini. If it reads ...
register_globals = on
... then you should be able to handle the $_REQUEST variables in the way you have them set up in your code. BUT ... BUT ... Don't rely on that directive. It is soon to die forever !! Do it the proper way, and use $_REQUEST, $_GET, $_POST, $_COOKIE etc ... and be futureproof for a few years to come.

(Hmmm ... Kriek ... as in Lambic ??)



[This message has been edited by trib a lot more times than it says below]

[This message has been edited by trib (edited 03-04-2003).]

DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 03-04-2003 14:09

Aside from that, I would think that having each input wrapped in it's own form, including the submit button, has to be causing problems. When the submit button is pressed, you're submitting whatever information is in "form1", which is nothing.

It's all one form - code it that way.

I would also think - although I don't really know for sure - that you would want to be using method="post" here rather than get.



[This message has been edited by DL-44 (edited 03-04-2003).]

shattered
Obsessive-Compulsive (I) Inmate

From:
Insane since: Feb 2003

posted posted 03-04-2003 21:27

Thank you all,
This problem is solved.
It's due the <form> tags, as DL-44 pointed out.
Thanks again!

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 03-04-2003 21:34

One last little tip

<?= $whatever ?>

is the same as <? echo $whatever ?>



.:[ Never resist a perfect moment ]:.

Kriek
Maniac (V) Inmate

From: Florida
Insane since: Jul 2001

posted posted 03-04-2003 23:30
quote:
Hmmm ... Kriek ... as in Lambic?



No, actually my last name Kriek (pronounced creek) was shortened from Kriekensento which is Italian =)
It wasn't up until a few years ago that I found out about Lindeman's Kriek (cherry flavored Lambic)

__________________

Kriek says '[SYSTEMWIDE_MESSAGE] PHP Meetup'
What we do is never understood; only praised and blamed

[This message has been edited by Kriek (edited 03-04-2003).]

DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 03-05-2003 02:40

I must admit that the image of kriek lambic has been the only thing in my mind every time I see your name (even though I've known it's your actual name!).
.

Glad to have helped, shattered. =)

« BackwardsOnwards »

Show Forum Drop Down Menu