user3000607
user3000607

Reputation: 3

Attribute values via php not giving a value

<input type="hidden" name="article_id" value="111">
<input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR'] ?>">
<input type="hidden" name="page" value="<?php echo $_SERVER['REQUEST_URI'] ?>"> 
<input type="hidden" name="date" value="<?php echo (date('F j, Y.')) ?>"> 
<input type="hidden" name="time" value="<?php echo (time()) ?>"> 

When I send the above values to the server using the post method, it returns blank value on the server using the $_POST, nothing shows up. When I use alert($form.find("input[name='page']").val()) it display this:

The page at 127.0.0.1 says:

<?php echo $_SERVER['REQUEST_URI'] ?>

I am using xampp on my local machine, if knowing this helps contributes to fixing the problem.

The other rest code such as:

<input type="hidden" name="article_id" value="111">
<input type="text" id="name" name="username" placeholder="Your name"/>

I get the values for those.

Upvotes: 0

Views: 93

Answers (2)

JaidynReiman
JaidynReiman

Reputation: 984

Whenever a file has any form of PHP code in it the extension must be PHP. PHP code will not be executed otherwise.

There are some ways to override this, but you'd have to redefine the mime types and its just not worth the effort. .php is the extension used for PHP pages, and if any PHP code is in your page, just name it .php.

Typically, if I know I'm going to be working with PHP code, I always name all my files .php anyway so I don't have to worry about changing them and messing up my URL's later.

Upvotes: 1

Joren
Joren

Reputation: 3297

Your PHP isn't running. If you have installed it you should be able to start it by going to your services window.

Upvotes: 0

Related Questions