Jump to content

How to Implement $_SERVER['PHP_SELF'] Into Echo?


chaseman

Recommended Posts

I'm trying to implement a form into the echo, and the $_SERVER['PHP_SELF'] part is causing errors.

 

Here's the code:

 

//Loop through the array of data
while ($row = mysqli_fetch_array($data)) 
{
	echo "<table padding='0' margin='0' class='knuffixTable'>";
	echo "<tr><td width='65px' height='64px' class='avatar_bg' rowspan='2' colpan='2'><img src='$avatar_path' alt='avatar' /></td><td class='knuffix_username'><strong>" . $user_name;
	echo "</strong><br />" . $row['category'] .  " | " . date('M d, Y', strtotime($row['contributed_date'])) . "</td></tr><tr><td>";
	echo "<form action='<?php echo" . $_SERVER['PHP_SELF'] . "; ?>' method='post'>
			<input type='submit' name='plusVote' value='Y' />
			<input type='submit' name='minusVote' value='N' />
			</form></td><td class='votes'>Y[ - ] | N[ - ]</td></tr>";
	echo "<tr><td class='knuffix_name' colspan='3'><strong>" . htmlentities($row['name']) . "</strong><br /></td></tr>";
	echo "<tr><td colspan='2' class='knuffix_contribution'><pre>" . $row['contribution'] . "</pre><br /></td></tr>";
	echo "</table>";
}

 

 

I tried all types of different variations it's simply not working.

 

I aöso tried adding the script file name into the action field when I then click the submit buttons the file itself is being loaded.

 

And with $_SERVER['PHP_SELF'] (as it is in the above example) I get an access denied error.

 

What is it that I'm doing wrong here?

Judging your signature, I'm guessing you're talking in GENERAL, not echo specific?

 

I would like to read that link in your signature, but unfortunately the link is broken.

 

I will try out your suggestion, though I'd appreciate if you could tell me how to implement $_SERVER['PHP_SELF'] correctly into the echo, not so I can do it, but just so I know how it's done. I'm just learning.  :shrug:

 

EDIT: just tried it out, it works, THANKS.

Archived

This topic is now archived and is closed to further replies.

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