Jump to content

simple post will not work


runnerjp

Recommended Posts

just this ismple post will not work :S is my code wrong or is it some other issue

 

it does not take me to the if (isset($_POST["edit"])) {  part

<link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css">
<link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/members/include/style.css">
<?php

error_reporting(E_ALL);
require_once '../settings.php';
checkLogin ('1');
$id=$_GET['id']; 
$query = "SELECT * FROM forumtutorial_posts where postid='$id'"; 
if ($result = mysql_query($query)){
    if (mysql_num_rows($result)) {
        $array = mysql_fetch_assoc($result);
        $title = $array['title'];
      
?>


<?php
if (isset($_POST["edit"])) { 
$title = $_POST['title'];


echo "Your title is  ". $title . "<br />";
echo "Thank you for ordering from Tizag Art Supplies!";
} else {
?>

<h4>test</h4>
<form action='<?php "$_SERVER[php_SELF]" ?>' method="post"> 

Title: 
  <input name="title" type="text" value="<?php echo $title;?>" /> 
<input type="submit" value="edit"/>
</form>
</body></html>
<?php }}}?>

Link to comment
https://forums.phpfreaks.com/topic/107970-simple-post-will-not-work/
Share on other sites

hey,

 

here is what i would do off the top of my head:

 

in place of your if statement where you check if the form is posted:

 

<?php
if ($_POST['title'] != "") { 

$title = $_POST['title'];


echo "Your title is  ". $title . "<br />";
echo "Thank you for ordering from Tizag Art Supplies!";
} else {
?>

Hey can you try this and see what it gives you:

 

<?php

error_reporting(E_ALL);
require_once '../settings.php';
checkLogin ('1');
$id=$_GET['id']; 

$query = "SELECT * FROM forumtutorial_posts where postid='$id'"; 
if ($result = mysql_query($query))]
{
if (mysql_num_rows($result)) 
{
	$array = mysql_fetch_assoc($result);
	$title = $array['title'];
      
	if ($_POST['title_field'] != "") 
	{ 
		echo "Your title is  ". $_POST['title_field'] . "<br />";
		echo "Thank you for ordering from Tizag Art Supplies!";
	} 
	else 
	{
	?>

	<h4>test</h4>
	<form action="<?php "$_SERVER[php_SELF]" ?>" method="post"> 

	Title: 
	  <input name="title_field" type="text" value="<?php echo $title;?>" /> 
	<input type="submit" value="edit"/>
	</form>
	</body>
	</html>
<?php 
	}
}
}
?>

try this


<link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css">
<link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/members/include/style.css">
<?php

error_reporting(E_ALL);
require_once '../settings.php';
checkLogin ('1');
$id=$_GET['id']; 
$query = "SELECT * FROM forumtutorial_posts where postid='$id'"; 
if ($result = mysql_query($query)){
    if (mysql_num_rows($result)) {
        $array = mysql_fetch_assoc($result);
        $title = $array['title'];
      
?>


<?php
if (isset($_POST["edit"])) { 
$title = $_POST['title'];


echo "Your title is  ". $title . "<br />";
echo "Thank you for ordering from Tizag Art Supplies!";
} else {
?>

<h4>test</h4>
<form action='<?php "$_SERVER[php_SELF]" ?>' method="post"> 

Title: 
  <input name="title" type="text" value="<?php echo $title;?>" /> 
<input type="submit" name="edit" value="edit"/>
</form>
</body></html>
<?php }}}?>

 

u can't get a html form element after form posting without giving a name to that element.

 

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.