Jump to content


Photo

[ask]guestbook. some fields blank on input


  • Please log in to reply
13 replies to this topic

#1 shrimp

shrimp
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 20 September 2006 - 02:41 PM

hello,
im nubi on php heheh.. and my st try is this guestbook http://sildeyna.trap...t/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

#2 shrimp

shrimp
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 20 September 2006 - 03:25 PM

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

this is the form


<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>




this is the handler :


<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>


anyone can help me with the error  :(

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 September 2006 - 03:35 PM

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;

<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>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 shrimp

shrimp
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 20 September 2006 - 05:42 PM

hi redarrow thanks for helping me

btw i did change the handler to this


<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>


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

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 September 2006 - 05:46 PM

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" />
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 shrimp

shrimp
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 20 September 2006 - 05:53 PM

its just says ERROR
which is i tink at the last if else bro..
::)

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 September 2006 - 05:57 PM

try this please cheers.
<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>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 shrimp

shrimp
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 20 September 2006 - 06:03 PM

oredi try bro but still. the msg is.. NO DATA INSERTED hehehe

this is my ugly form


<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>




sorry trouble u bro

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 September 2006 - 06:04 PM

try this out
<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>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 September 2006 - 06:17 PM

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 .
<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>





<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>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#11 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 September 2006 - 06:33 PM

afther all that look at your insert $query you got a extra ;

should be ";
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#12 shrimp

shrimp
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 20 September 2006 - 07:28 PM

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...k/guestbook.zip
Database name : test
Table              : guestbook
username        : root
no password.

Many thanks for the help n time bro..

#13 shrimp

shrimp
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 21 September 2006 - 03:09 AM

hello redarrow. do u hav im? if u dun mind :)

#14 shrimp

shrimp
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 21 September 2006 - 04:10 AM

redarrow thanks. solve it oredi... the thing is just 'submit' need to changed to 'Submit' hiks.. hehehe THANKS A LOT BRO! :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users