Jump to content

it doesnt work but neither a error


clankill3r

Recommended Posts

I have a quite old book about database applications, and i got a problem with it.

I have this page, create_entry.php

 

<?php
include("dbconnect.php");

if ($submit == "Sign") {
$query = "insert into DA_guestbook(name, location, email, url, comments) values ('$name', '$location', '$email', '$url', '$comments')";
mysql_query($query) or die (mysql_error());
?>
<h2>Thanks!!</h2>
<h2><a href="view.php">View my guestbook!</a></h2>
<?php
}
else {
include("sign.php");
}
?>

 

and i got this page named sign.php

 

<h2>Sign my guestbook</h2>
<form method="post" action="create_entry.php">
<b>Name:</b>
<input type="text" size="40" name="name">
</br>
<b>Location:</b>
<input type="text" size="40" name="location">
</br>
<b>Email:</b>
<input type="text" size="40" name="email">
</br>
<b>Home Page Url:</b>
<input type="text" size="40" name="url">
</br>
<b>Comments:</b>
<textarea name="comments" cols="40" rows="4" wrap="virtual"></textarea>
</br>
<input type="submit" name="submit" value="Sign">
<input type="reset" name="reset" value="Start Over">
</form>

 

When i open create_entry.php then sign.php is indeed shown up.

However when i send, it brings me to the same page with no Thanks!! etc.

Also nothing gets inserted in the database.

 

Hope i explained well enough

Link to comment
https://forums.phpfreaks.com/topic/246775-it-doesnt-work-but-neither-a-error/
Share on other sites

you need to add all your name references to post the variables

 

 


<?php

if($_POST['submit']){
$name=$_POST['name'];
$location=$_POST['location'];

// do what ever with the posted variables.
}
?>

 

Also i agree, your book out dated, wrong php book version,your studying php 3/4 but using php 5/nearly 6.

Try this for a example might work.

 

Warning all the information needs validating........

 

<?php
include("dbconnect.php");

if ($_POST['submit'] == "Sign") {

$name=$_POST['name'];
$location=$_POST['location'];
$email=$_POST['email'];
$url=$_POST['url'];
$comments=$_POST['comments'];

$query = "insert into DA_guestbook(name, location, email, url, comments) values ('$name', '$location', '$email', '$url', '$comments')";
mysql_query($query) or die (mysql_error());
?>
<h2>Thanks!!</h2>
<h2><a href="view.php">View my guestbook!</a></h2>
<?php
}
else {
include("sign.php");
}
?>

 

 

 

<h2>Sign my guestbook</h2>
<form method="post" action="create_entry.php">
<b>Name:</b>
<input type="text" size="40" name="name">
</br>
<b>Location:</b>
<input type="text" size="40" name="location">
</br>
<b>Email:</b>
<input type="text" size="40" name="email">
</br>
<b>Home Page Url:</b>
<input type="text" size="40" name="url">
</br>
<b>Comments:</b>
<textarea name="comments" cols="40" rows="4" wrap="virtual"></textarea>
</br>
<input type="submit" name="submit" value="Sign">
<input type="reset" name="reset" value="Start Over">
</form>

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.