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?

Link to comment
Share on other sites

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.

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.