Jump to content

Problem with Form action (php) function


mndasari

Recommended Posts

Hi,

I am new to php & have a question about form's action func. My html file contains a form, having method="post" and action="filename.php". This filename.php is in the same dir as of html. I show html page in browser, hit submit button, it executes php script and shows output. But the problem is, now, if I modify php file e.g. add an echo statement, new changes donot get executed at all, same old output is still shown in the browser.

 

Instead, if I run this php script at command line, it works fine.

Could you please help!

Thanks.

Link to comment
Share on other sites

Code is here ...

File: new_form.html

<html>

<body>

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

Enter user id: <input type=text name=user_id>

<input type=submit value="Submit">

</form>

</body>

</html>

 

File: new_scr.php

<?php

  $username="xxx";

  $password="yyy";

  $database="zzz";

 

  mysql_connect(localhost,$username,$password);

  @mysql_select_db($database) or die( "Unable to select database");

  $user_id = $_POST['user_id']; 

  $qry = "SELECT * FROM user_tbl where user_id = '" . $user_id . "'";

  $result = mysql_query( $qry ) or die(mysql_error());

  $row = mysql_fetch_array($result);

  $user_name = $row['last_name'] . ", " . $row['first_name'];

  echo "User name: " . $user_name;

  echo "Script ended.";

?>

 

Here, new_scr.php is printing user name correctly. Later I added line in red color to php file, I reloaded the form in the same browser window (same session) and hit submit button but new echo statement is not printed- somehow its executing the original .php file again (new changes are not effective). I tried clearing browser cache but didnot work.

Any suggestions would greatly help!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.