variable passing

0 reema dawes · September 11, 2014
<form action="page2.php" method="post">
title <input type="text" name="title" >
content <input type="text" name="content">
homepage <input type="checkbox" name="chk" value="yes">
<input type="submit" name="submit" value="submit">
<?php
if (isset($_POST['submit']))
$title= $_POST['title'];
$content=$_POST ['content'];
$chk=$_POST['chk'];
if ( $title=='' or $content==''){
echo"enter all fields";
}
else {
$query=INSERT into posts VALUE ('',$title,'$content,'')
}
if ($query_run=mysql_query($query) {
echo "successful";
}

if (isset($_POST['chk'])&& $chk=='yes'))
while ($row=mysql_fetch_assoc($query_run)){
echo "<a href=\"index.php?id=".$row['id']."/> </a>";
}





?>

Post a Reply

Replies

- page 1
Oldest  Newest  Rating
+1 Franz Schmidt · September 11, 2014
What is with this code?
+1 Franz Schmidt · September 12, 2014
And whats your problem?
+1 JOhaL jaTT · September 12, 2014
try this  


id =   $row['id'];

echo '<a href="index.php?id='.$id.' ">'.$id.' </a>'; 



if you tell me about sql table structure then i will help you more also index page
and one thing i mast consider OR  EXPRESSION 


HERE 
if ( $title=='' or $content=='') it mast be    if ( $title=='' || $content=='')

use OR EXPRESSION ( ||  )  instead of word  "or"
+1 Franz Schmidt · September 12, 2014
Could you post your index.php to?
+1 Franz Schmidt · September 12, 2014
At the beginning you posted a code is this the index.php or another page of yours?
0 reema dawes · September 12, 2014
i am trying to get the specific data of the column id from the database if the checkbox is clicked, so the information should pass to index.php otherwise it just inserts into the database.
0 reema dawes · September 12, 2014
my problem is the data isn't being passed to the index.php page, it does the insert into the database but when i go to index.php its blank
0 reema dawes · September 12, 2014
mysql table structure is 
id    title    content      with id being the primary key which auto increments 
0 JOhaL jaTT · September 12, 2014
Posting error
0 JOhaL jaTT · September 12, 2014
Alright this works but chat section not working
  • 1
  • 2

PHP

106,963 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators