Page 1 of 1

What Am i doing wrong?

Posted: Sun Mar 28, 2004 12:18 pm
by crazytopu
I would highly appreciate any kind of help.


This is where i input my call_no of the book on which i want to make some modification. the test.php page is called upon click on getvalue button...

Code: Select all

<?php


<form method="post" action="test.php"> 

<table border="0" width="75%"> 
  <tr> 
    <td width="15%">
      <p align="right">Call No:</p>
    </td> 
    <td width="57%"><input type="text" name="call_no" size="20"></td> 
    
  </tr> 
  <tr> 
    <td width="15%"> 

    </td> 
    <td width="57%"> 

 <input type="submit" value="Get Value" name="getvalue">

</p> 
</form> 



?>


Can anybody tell why am i not getting the expected msg when i click on update button?




Code: Select all

<?php

<html>
<head></head>
<body>

<?php

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

echo "Update works now!! congratulations!!!!\n"; 

}



else {



$db = mysql_connect("localhost", "root"); 

mysql_select_db("library",$db); 

$sql = "SELECT * FROM book WHERE call_no=('{$_POST['call_no']}')";

$result = mysql_query($sql); 


while ($myrow = mysql_fetch_row($result)) 
{ 


echo
'<table border="0" width="75%"> 
  <tr> 
    <td width="15%">Call No</td> 
    <td width="62%"><input type="text" name="call_no" value ="'.$myrow[0].'" size="20"></td> 
  </tr> 
  <tr> 
    <td width="15%">Book Title</td> 
    <td width="62%"><input type="text" name="title" value ="'.$myrow[1].'"size="20"></td> 
  </tr> 
  <tr> 
    <td width="15%">Author1</td> 
    <td width="62%"><input type="text" name="author1" value ="'.$myrow[2].'" size="20"></td> 
    
  </tr> 
  <tr> 
    <td width="15%">Author2</td> 
    <td width="62%"><input type="text" name="author2" value= "'.$myrow[3].'"size="20"></td> 
    
  </tr> 
  <tr> 
    <td width="15%">Publisher</td> 
    <td width="85%" colspan="2"><input type="text" name="publisher" value ="'.$myrow[4].'"size="20"></td> 
  </tr> 
  <tr> 
    <td width="15%">ISBN</td> 
    <td width="85%" colspan="2"><input type="text" name="isbn" value = "'.$myrow[5].'"size="20"></td> 
  </tr> 
  <tr> 
    <td width="15%">Price</td> 
    <td width="85%" colspan="2"><input type="text" name="price" value ="'.$myrow[6].'"size="20"></td> 
  </tr> 
  <tr> 
    <td width="15%">No of Page</td> 
    <td width="85%" colspan="2"><input type="text" name="no_of_page" value="'.$myrow[7].'" size="20"></td> 
  </tr> 
  <tr> 
    <td width="15%">Edition</td> 
    <td width="85%" colspan="2"><input type="text" name="edition" value="'.$myrow[8].'"size="20"></td> 
  </tr> 
  <tr> 
    <td width="15%">Category</td> 
    <td width="85%" colspan="2"><input type="text" name="category" value="'.$myrow[9].'" size="20"></td> 
  </tr> 
</table> 
<p> 



';


} //end of while loop



} // end if 


?> 


<input type="submit" value="Update" name="Update"> 

    
</body>

?>

Posted: Sun Mar 28, 2004 12:39 pm
by m3mn0n
Check your variable names.

Posted: Sun Mar 28, 2004 8:01 pm
by crazytopu
Hi,

I didnot get your point. Which variable name to check? I can display the data into the text box, no proble. The only problem is when i hit the update button nothing happens. I mean i dont get the messege

Code: Select all

<?php
echo "Update works now!! congratulations!!!!\n"; 
?>
When i hit the update button. Apart from this the other part of the code is just fine.

Posted: Sun Mar 28, 2004 8:10 pm
by danyprundus
Here's the solution
In your from you use4 this:

<input type="submit" value="Get Value" name="getvalue">

Than, on test.php you use this:

Code: Select all

<?php

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

echo "Update works now!! congratulations!!!!\n"; 

} 

?>
But you shoud use $_POST['getvalue'] instead of $_POST['Update'].
ok?
:)

Posted: Sun Mar 28, 2004 9:43 pm
by markl999
I don't see any <form></form> tags in test.php , so $_POST['Update'] will never be set.

Posted: Sun Mar 28, 2004 10:01 pm
by litebearer
Aside from the issues already addressed, I am seeing straight html between the opening and closing php tags as well as embeding within the opening and closing tags...
<?php

<html>
<head></head>
<body>

<?php

if (isset($_POST['Update'])) {
could that possibly contribute to the problem?

Lite...

Posted: Sun Mar 28, 2004 10:31 pm
by Illusionist
litebearer, that was probably done by the [syntax=php][/syntax] tags. He probably doesn't have thsoe in his actual script.

Posted: Mon Mar 29, 2004 2:55 am
by crazytopu
Illusionist is right..i dont get that piece of code in my actual code..but thanks to litebearer for peeling his eyes like that!

markl999, I did not notice that..it is solved now..thanks..


danyprundus, i dont see any point of using getvalue instead of Update. did you really get my point what i wanted?