What Am i doing wrong?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
crazytopu
Forum Contributor
Posts: 259
Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:

What Am i doing wrong?

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

?>
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Check your variable names.
crazytopu
Forum Contributor
Posts: 259
Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:

Post 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.
danyprundus
Forum Newbie
Posts: 4
Joined: Sun Mar 28, 2004 8:10 pm

Post 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?
:)
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

I don't see any <form></form> tags in test.php , so $_POST['Update'] will never be set.
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Post 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...
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

litebearer, that was probably done by the [syntax=php][/syntax] tags. He probably doesn't have thsoe in his actual script.
crazytopu
Forum Contributor
Posts: 259
Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:

Post 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?
Post Reply