Categories > TinyButStrong general >

problem with forms...

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Mankiy
Date: 2003-07-11
Time: 23:34

problem with forms...

Im having a problem with forms and the PHP....

its not sending it to the PHP i dont think.......

heres the PHP code:
<?php

   require("config.php");
   require_once($clsdir."tpl_class.php");


$PAGE = new tpl_class;
$PAGE->LoadTemplate($tpldir."post.tpl");


// session start and check
session_start();
$username = $_SESSION["username"];
$password = $_SESSION["password"];

$PAGE->MergeField("TITLE", "Post");

   $topic = $HTTP_POST_VARS[topic];
   $message = nl2br($HTTP_POST_VARS[post]);
   $date = date("Y-m-d H:i:s");
   $fid = $_GET[f];

if (!isset($username)) {
$username = $HTTP_POST_VARS[username];
}

if ($Submit == "Submit") {
$sql = @mysql_query("INSERT INTO hyperbb_topics SET
         posted_by='$username',
         last_post='$username',
         sub_ID='$fid',
         topic_name='$topic',
         last_date='$date'");

if (!$sql) {
echo("<font color=\"#800000\">Error Posting: " . mysql_error() . "</font>");
}


$lastID = mysql_insert_id();
$sql = @mysql_query("INSERT INTO hyperbb_posts SET
         posted_by='$username',
         topic='$topic',
         post_text='$message',
         topic_ID='$lastID',
         post_date='$date'");

if (!$sql) {  
   echo("<font color=\"#800000\">Error Posting: " . mysql_error() . "</font>");
} else {
echo("Dont even think about it, successful :P");
}}
$PAGE->show();
?>

and the html code:
<html>
<head>
<title> {TITLE} </title>
</head>
<body bgcolor="#FFFFFF">

<form action="post.php" method="post">
<table bgcolor="#000000" border="0" cellspacing="1" cellpadding="0" width="500"> 

<tr><td bgcolor="#000099" width="200">
    &nbsp; Guest Name: </td>
      <td bgcolor="#FFCC99" width="500" height="40">
    &nbsp;<input type="Text" name="username" maxlength="20" size="20"><br>
  </td></tr>

  <tr><td bgcolor="#000099" width="200">
    &nbsp; Topic: </td>
      <td bgcolor="#FFCC99" width="500" height="40">
    &nbsp;<input type="Text" name="topic" maxlength="50" size="50"><br>
  </td></tr>

<tr><td bgcolor="#000099" width="200">
    </td>
      <td bgcolor="#FFCC99" width="500">
    &nbsp;<textarea name="post" rows="10" cols="50" wrap="off"></textarea>
  </td></tr>
</table>

<table border="1" cellspacing="0" cellpadding="0" width="500">
<tr><td width="100%" bgcolor="#FFCC99">
<center><input type="submit" name="Submit" value="Submit"></center>
</td></tr>
</table>
</form>

</body>
</html>

do you see any probs there?
By: Skrol29
Date: 2003-07-15
Time: 14:06

Re: problem with forms...

Hello Mankiy,

Here what I see:
1/
some of your items of arrays are not string delimited.
  $topic = $HTTP_POST_VARS[topic];
should be
  $topic = $HTTP_POST_VARS['topic'];

2/
  $fid = $_GET[f];
This line won't work because 'f' is not given by GET a method.
By: Mankiy
Date: 2003-07-15
Time: 17:38

Re: problem with forms...

f is taken from the URL
ex: http://localhost/forum1/post.php?f=1
By: Skrol29
Date: 2003-07-16
Time: 10:03

Re: problem with forms...

But it is not in the definition of the form :

<form action="post.php" method="post">
By: Mankiy
Date: 2003-07-19
Time: 21:23

Re: problem with forms...

It still isnt working, i changed these: $HTTP_POST_VARS['string']

and i changed $_GET[f] to $_POST[f]

and it still wont work for me...
By: robee
Date: 2003-08-18
Time: 11:47

Re: problem with forms...

geh!the date was last july 19..but anyways, what i've noticed , in your html :

<input type="Text" name="username" maxlength="20" size="20">

i think u forgot to put a value="[var.username]" in ur forms..