Jump to content

[ask]guestbook. some fields blank on input


shrimp

Recommended Posts

hello,
im nubi on php heheh.. and my st try is this guestbook http://sildeyna.trap17.net/guestbook.php
the problem is when we input the name email n comment. it wont popup on the handler. and as the results it inputs nothing on the database. i dunno because of what. anyone help me pleasee :((( thank u so much
Link to comment
https://forums.phpfreaks.com/topic/21414-askguestbook-some-fields-blank-on-input/
Share on other sites

anyone can help ? anyway this is what i type on,

this is the form
[quote]

<html>
<link href="style.css" rel="stylesheet" type="text/css" />
<body>


<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td class="halo"><strong>Test Sign Guestbook </strong></td>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td class="halo"><strong><a href="viewguestbook.php">View Guestbook</a> </strong></td>
</tr>
</table>
<form id="form2" name="form2" method="post" action="addguestbook.php">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="halo">
    <tr>
      <td width="147" class="halo">Name</td>
      <td width="353" class="halo"> :
          <label>
          <input name="name" type="text" id="name" />
          </label>
      </td>
    </tr>
    <tr>
      <td class="halo">Email</td>
      <td class="halo"> :
        <input name="email" type="text" id="email" />
      </td>
    </tr>
    <tr>
      <td class="halo">Comments</td>
      <td class="halo"> :
          <label>
          <textarea name="comment" cols="40" id="comment"></textarea>
          </label>
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td class="halo">
        <label>
        <input type="submit" name="Submit" value="Submit" />
        </label>
      </td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
</body>
</html>


[/quote]


this is the handler :
[quote]

<html>
<link href="style.css" rel="stylesheet" type="text/css" />
<body>


<p>
  <?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="guest"; // Database name
$tbl_name="guestbook"; // Table name

echo "$name";

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");

$datetime=date("y-m-d h:i:s"); //date time

$sql="INSERT INTO $tbl_name(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime');";
$result=mysql_query($sql);

//check if query successful
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='viewguestbook.php'>View guestbook</a>"; // link to view guestbook page
}

else {
echo "ERROR";
}

mysql_close();
?>
</p>
</body>
</html>

[/quote]

anyone can help me with the error  :(
fill in the xxx and then select the insert colum try ok.

in your form put upercase POST

i also added the POST[''] and addslashes statement ok;

[code]
<html>
<link href="style.css" rel="stylesheet" type="text/css" />
<body>


<p>

<?php

$db=mysql_connect("xxlocalhostxx","xxusernamexx","xxpasswordxx");
mysql_select_db("xxdatabasexx",$db);

$name=addslashes($_POST['name']);
$email=addslashes($_POST['email']);
$comment=addslashes($_POST['comment']);
$datetime=addslashes($_POST['datetime']);

$datetime=date("y-m-d h:i:s"); //date time

if($_POST['submit']){

$sql="INSERT INTO xxcolumnamexx(`name`, `email`, `comment`, `datetime`)VALUES('$name', '$email', '$comment', '$datetime');";
$result=mysql_query($sql);
}
//check if query successful
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='viewguestbook.php'>View guestbook[/url]"; // link to view guestbook page
}

else {
echo "ERROR";
}

mysql_close();
?>
</p>
</body>
</html>
[/code]
hi redarrow thanks for helping me

btw i did change the handler to this
[quote]

<html>
<link href="style.css" rel="stylesheet" type="text/css" />
<body>


<p>

<?php

$db=mysql_connect("localhost","root","")or die("GAK BISA KONEK");
mysql_select_db("guest",$db);

$name=addslashes($_POST['name']);
$email=addslashes($_POST['email']);
$comment=addslashes($_POST['comment']);
$datetime=addslashes($_POST['datetime']);

$datetime=date("y-m-d h:i:s"); //date time

if($_POST['submit']){

$sql="INSERT INTO guestbook(`name`, `mail`, `comment`, `datetime`)VALUES('$name', '$email', '$comment', '$datetime');";
$result=mysql_query($sql);
}
//check if query successful
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='viewguestbook.php'>View guestbook[/url]"; // link to view guestbook page
}

else {
echo "ERROR";
}

mysql_close();
?>
</p>
</body>
</html>

[/quote]

but its error. when i press submit
btw i dunno what u mean uppercase post. i did put post method. thanks a lot for the explanation mate.
God Bless
post the errors please cheers.

POST - upercase
post  - lowercase

<form id="form2" name="form2" method="post" action="addguestbook.php">

to

<form method="POST" action="addguestbook.php">



make sure that the form inputs are correct as i only use html  and you use xhtml so cheek ok.
<input name="email" type="text" id="email" />
try this please cheers.
[code]
<html>
<link href="style.css" rel="stylesheet" type="text/css" />
<body>
<p>

<?php

$db=mysql_connect("localhost","root","")or die("GAK BISA KONEK");
mysql_select_db("guest",$db);

$name=addslashes($_POST['name']);
$email=addslashes($_POST['email']);
$comment=addslashes($_POST['comment']);
$datetime=addslashes($_POST['datetime']);

$datetime=date("y-m-d h:i:s"); //date time

if($_POST['submit']){

$sql="INSERT INTO guestbook(`name`, `mail`, `comment`, `datetime`)VALUES('$name', '$email', '$comment', '$datetime');";
$result=mysql_query($sql);
echo"data inseted";
exit;
}else{
echo "no data inserted";
exit;
}
?>
</p>
</body>
</html>
[/code]
oredi try bro but still. the msg is.. NO DATA INSERTED hehehe

this is my ugly form
[quote]

<html>
<link href="style.css" rel="stylesheet" type="text/css" />
<body>


<p>
<form method="POST" action="addguestbook1.php">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td width="145" class="halo">Name</td>
      <td width="355" class="halo"> :
        <input name="name" type="text" id="name">
      </td>
    </tr>
    <tr>
      <td class="halo">Email</td>
      <td class="halo"> :
        <input name="email" type="text" id="email">
      </td>
    </tr>
    <tr>
      <td class="halo">Comments</td>
      <td class="halo"> :
          <textarea name="comment" cols="40" id="comment"></textarea>
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td class="halo">
        <label>
        <input type="submit" name="Submit" value="submit" >
        </label>
      </td>
    </tr>
  </table>
</form>
</p>
</body>
</html>



[/quote]

sorry trouble u bro
try this out
[code]
<html>
<link href="style.css" rel="stylesheet" type="text/css" />
<body>


<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td class="halo">
<strong>Test Sign Guestbook</strong></td>
</tr>
</table>

<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td class="halo"><strong><a href="viewguestbook.php">View Guestbook[/url] </strong></td>
</tr>
</table>

<form method="post" action="addguestbook.php">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="halo">
    <tr>
      <td width="147" class="halo">Name</td>
      <td width="353" class="halo"> :
          <label>
          <input name="name" type="text">
          </label>
      </td>
    </tr>
    <tr>
      <td class="halo">Email</td>
      <td class="halo"> :
        <input name="email" type="text" >
      </td>
    </tr>
    <tr>
      <td class="halo">Comments</td>
      <td class="halo"> :
          <label>
          <textarea name="comment" cols="40" ></textarea>
          </label>
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td class="halo">
        <label>
        <input type="submit" name="Submit" value="Submit" />
        </label>
      </td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
</body>
</html>
[/code]
try this ok i tested the form and works know so you now need to test the database as i have not got yours ok.

once that done were also add some valadation .
[code]
<html>
<link href="style.css" rel="stylesheet" type="text/css" />
<body>


<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td class="halo">
<strong>Test Sign Guestbook</strong></td>
</tr>
</table>

<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td class="halo"><strong><a href="viewguestbook.php">View Guestbook[/url] </strong></td>
</tr>
</table>

<form method="post" action="addguestbook.php">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="halo">
    <tr>
      <td width="147" class="halo">Name</td>
      <td width="353" class="halo"> :
          <label>
          <input type="text" name="name">
          </label>
      </td>
    </tr>
    <tr>
      <td class="halo">Email</td>
      <td class="halo"> :
        <input type="text" name="email" >
      </td>
    </tr>
    <tr>
      <td class="halo">Comments</td>
      <td class="halo"> :
          <label>
          <textarea name="comment" cols="40" ></textarea>
          </label>
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td class="halo">
        <label>
        <input type="submit" name="Submit" value="Submit">
        </label>
      </td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
</body>
</html>

[/code]



[code]

<html>
<link href="style.css" rel="stylesheet" type="text/css" />
<body>
<p>

<?php

$db=mysql_connect("localhost","root","")or die("GAK BISA KONEK");
mysql_select_db("guest",$db);

$name=addslashes($_POST['name']);
$email=addslashes($_POST['email']);
$comment=addslashes($_POST['comment']);
$datetime=addslashes($_POST['datetime']);

$datetime=date("y-m-d h:i:s"); //date time

if($_POST['submit']){

$sql="INSERT INTO guestbook(`name`, `mail`, `comment`, `datetime`)VALUES('$name', '$email', '$comment', '$datetime')";
$result=mysql_query($sql);
echo"data inseted";
exit;
}else{
echo "no data inserted";
exit;
}
?>
</p>
</body>
</html>
[/code]
oredi fixed and try it out bro.. still no clue y this still no data insert.
if u dun mind, below i zip my file n screenshot of phpmyadmin mysql table..

http://geocities.com/butter_punk/guestbook.zip
Database name : test
Table              : guestbook
username        : root
no password.

Many thanks for the help n time bro..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.