php form problems

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

startech
New php-forum User
New php-forum User
Posts: 12
Joined: Mon Jun 30, 2003 10:54 am

php form problems

Postby startech » Wed Jul 09, 2003 7:56 am

Trying to create a form and the $phone variable only works up to "if ($submit){" then it stops passing it...

Any ideas?

<-----Begin Code---->
<html>
<head>
<title>Add Info</title>
</head>
<body>
<?php
$phone = $_GET['phone'];
$date = `date | awk '{print $2, $3, $6}'`;
print "<center>
<b><font size=+1 color=red>NO RECORDS FOUND</FONT></B><br>
<b>Please enter information in all fields</b><br>
<font color=#FF0000 size=1 face=Arial>*note: Do not use spaces or dashes</font></font></p>";
?>
<form method=post action="<?php echo $PHP_SELF?>">
<?
print "Phone:<input type=Text name=phone value=$phone><br>
Item:&&<input type=Text name=item><br>
Notes:<textarea rows=5 name=notes cols=23></textarea><br>
<input type=Submit name=submit value=Submit>
<br>";

if ($submit){
// process form

$db = mysql_connect("localhost", "someuser", "somepass");

mysql_select_db("sales",$db);

$sql = "INSERT INTO data (phone, item, notes, date) VALUES ('$phone','$item','$notes','$date')";

$result = mysql_query($sql);

echo "Thank you! Information entered.\n";
echo "<script language=javascript>window.location.href=\"https://www.somehost.net/sales/\"</script>";
}
?>
</center>
</body>
</html>

liquedus
php-forum Active User
php-forum Active User
Posts: 266
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada
Contact:

Postby liquedus » Wed Jul 09, 2003 10:01 am

try:

$_GET['submit']

or $_POST['submit']

and this subject has been posted about in other threads on this forum... :wink:

startech
New php-forum User
New php-forum User
Posts: 12
Joined: Mon Jun 30, 2003 10:54 am

Postby startech » Wed Jul 09, 2003 12:17 pm

Thanks!,

Racked my brain on this one for half the day. :lol:

liquedus
php-forum Active User
php-forum Active User
Posts: 266
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada
Contact:

Postby liquedus » Wed Jul 09, 2003 2:44 pm

yes, alot of online tutorials and examples use just : if($submit)

however to my knowledge this has been disabled now.


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron