Jump to content

[SOLVED] Information Not Being Stored


Bopo

Recommended Posts

Hi

 

This has had me pulling my hair out, I can't see any problems, I tried testing by echoing out my variables and the result is always blank, I have a very similar piece of code on another page and this is almost identical apart from form elements and table names. The problem is that nothing is being stored in $fname $lname and $title, I have tried many different approaches but the outcome is always the same, blank.

 

<?php

$idvalue = $_GET['id'];

if(isset($_POST['save'])) {

if(empty($_POST['fname']) && empty($_POST['lname']) && empty($_POST['title']) && empty($_POST['FCKeditor1'])) {
   die('Please fill in all required fields');
}

$fname = ($_POST['fname']);
$lname = ($_POST['lname']);
$title = ($_POST['title']);
$post = ($_POST['FCKeditor1']); 

echo $fname;
echo $lname;
echo $title;

exit();

include("blogconnect.php");

$sql = "UPDATE blogposts SET firstname = '$fname', lastname = '$lname', title = '$title', post = '$post' WHERE id = '$idvalue'";
if(!mysql_query($sql, $connect)) {
	die('Error' . mysql_error());		
}
echo '<p>Record sucesfully updated, <a href="http://www.koicarpadvice.com/admin/posts.php">Return to posts</a></p>';
mysql_close($connect);
}

?>

 

  <?php 

$idvalue = $_GET['id'];

include("blogconnect.php");

$sql = "SELECT * FROM blogposts WHERE id = '$idvalue'"; 

$query = mysql_query($sql, $connect); 
while ($row = mysql_fetch_assoc($query)) {

echo '<form id="form1" name="form1" method="post" action="" class="form">
      <label for="author">First Name:</label>
      <input name="author" type="text" class="inputbox" id="fname" value="' . $row['firstname'] . '" /><br /><br />
  
  <label for="author">Last Name:</label>
      <input name="author" type="text" class="inputbox" id="lname" value="' . $row['lastname'] . '" /><br /><br />
  
  <label for="author">Title:</label>
      <input name="author" type="text" class="inputbox" name="title" id="title" value="' . $row['title'] . '" /><br /><br />';
  
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = '/fckeditor/' ;
$oFCKeditor->Value = $row['post'];
$oFCKeditor->Create() ;

}

?>

Link to comment
https://forums.phpfreaks.com/topic/155524-solved-information-not-being-stored/
Share on other sites

<?php 

$idvalue = $_GET['id'];
include("blogconnect.php");
$sql = "SELECT * FROM blogposts WHERE id = '$idvalue'";
$query = mysql_query($sql, $connect);
while ($row = mysql_fetch_assoc($query)) {
	echo '<form id="form1" name="form1" method="post" action="" class="form">
      <label for="author">First Name:</label>
      <input name="fname" type="text" class="inputbox" id="fname" value="' . $row['firstname'] . '" /><br /><br />
     <label for="author">Last Name:</label>
      <input name="lname" type="text" class="inputbox" id="lname" value="' . $row['lastname'] . '" /><br /><br />
     <label for="author">Title:</label>
      <input name="title" type="text" class="inputbox" name="title" id="title" value="' . $row['title'] . '" /><br /><br />';
	$oFCKeditor = new FCKeditor('FCKeditor1') ;
	$oFCKeditor->BasePath = '/fckeditor/' ;
	$oFCKeditor->Value = $row['post'];
	$oFCKeditor->Create() ;
}
}
?>

you weren't setting the input NAMES. just the id's

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.