Jump to content

[SOLVED] action="<?=$_SERVER['PHP_SELF']?>"


gamerzfuse

Recommended Posts

I am following an old PHP tutorial from 2003.

 

They advised to use the following string for my Form Action:

 

<form method="post" action="<?=$_SERVER['PHP_SELF']?>">

 

Now when i hit submit on the form it simply comes up with a Page Not Found Error as it tries to access the url:

 

http://www.example.com/<?=$_SERVER['PHP_SELF']?>

 

Is there a new way to do this?

Could I simply make the action say

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

?

 

Thanks in advance!

 

 

EDIT: Additional Information (Original instructions)

 

Notice the action attribute. In a familiar design pattern, which I have called multipurpose pages in previous articles, we are causing the form to be submitted to the same page containing the form code. By watching for the PHP variable $_POST['submitok'], which will be created by the submit button in this form (notice name="submitok" in the tag), our script will be able to handle the form submissions as well as the display of the form itself.

We're also using a relatively new form of syntax to print out the $_SERVER['PHP_SELF'] variable. In case you are unfamiliar with this syntax, allow me to clarify that <?=expression?> is functionally identical to <?php echo expression; ?>. Thus, in this case, we could have instead written the following:

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

Link to comment
Share on other sites

welcome to 2009!

 

working with form actions is an HTML issue .. but yes, you can put in a file as the action.

 

you're pointing the action to whatever script/file is going to be processing the form.

 

<?=$_SERVER['PHP_SELF']?> is just reloading the page and should be <?php echo $_SERVER['PHP_SELF']; ?> instead.

Link to comment
Share on other sites

welcome to 2009!

 

working with form actions is an HTML issue .. but yes, you can put in a file as the action.

 

you're pointing the action to whatever script/file is going to be processing the form.

 

<?=$_SERVER['PHP_SELF']?> is just reloading the page and should be <?php echo $_SERVER['PHP_SELF']; ?> instead.

 

 

Unfortunately this gives me the exact same error with your code in the URL instead of the original code.

I understand that this may start as an HTML issue, but it is based around PHP and these are the best forums I have found for quick and accurate results.

 

EDIT: Pointing to signup.php and a minor code change in that file made it all work.

 

Now I'm just getting a Database Down error because I don't have my database parameters set up properly. Need to find database name, figure out if user has a prefix (ie: gamerzfu_user or just user) and get my password.

 

SOLVED: Used username with the prefix for database name AND username from my bluehost account.

 

 

Thanks.

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.