3 Replies - 1295 Views - Last Post: 01 April 2013 - 03:05 AM Rate Topic: -----

#1 vv411  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 31-March 13

form won't post to same page properly

Posted 31 March 2013 - 05:40 PM

I'm making a web calendar using the xampp server, and on the login page, I have a form that is supposed to post to itself and then redirect to another page if the user is logged in, but when the form is submitted, instead of redirecting to the page itself which is located at localhost/calendar/index.php it goes to just calendar/index.php without the localhost. I tried changing the action to index.php but it does it wrong for that also.



The code for the form is
<form action="<?php echo $SCRIPT_NAME; ?>" method="POST">
<table>
 <tr>
  <td>username</td>
  <td><input type="text" name="userbox">
 </tr>
 <tr>
  <td>password</td>
  <td><input type="password" name="passbox">
 </tr>
 <tr>
  <td></td>
  <td><input type="submit" name="submit" value="Log in">
 </tr>
</table>
</form>




the script_name var is
$SCRIPT_NAME = $_SERVER['SCRIPT_NAME'];

I don't know enough this to know what is causing it to go the wrong directory.

Is This A Good Question/Topic? 0
  • +

Replies To: form won't post to same page properly

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5388
  • View blog
  • Posts: 27,384
  • Joined: 10-May 07

Re: form won't post to same page properly

Posted 31 March 2013 - 05:43 PM

If you change the variable & hard code in the actual page name, does the form work?
Was This Post Helpful? 0
  • +
  • -

#3 vv411  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 31-March 13

Re: form won't post to same page properly

Posted 31 March 2013 - 05:51 PM

View Postno2pencil, on 31 March 2013 - 05:43 PM, said:

If you change the variable & hard code in the actual page name, does the form work?


well i tried taking out the echo and just putting

action = "index.php" which is the name of the page and it didn't go to the localhost directory
and when I tried "localhost/calendar/index.php" it went to
localhost/calendar/localhost/calendar.index.php ...
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,441
  • Joined: 08-June 10

Re: form won't post to same page properly

Posted 01 April 2013 - 03:05 AM

assuming your current file is localhost/calendar/index.php then index.php (a relative path) uses the same directory (i.e. localhost/calendar/index.php). using localhost/calendar/index.php (another relative path) also appends to the current directory (localhost/calendar/localhost/calendar/index.php). what you need is an absolute path.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1