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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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