chaseman Posted February 19, 2011 Share Posted February 19, 2011 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? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 19, 2011 Share Posted February 19, 2011 Do not use $_SERVER['PHP_SELF'] as a form action. Simply use action="" Quote Link to comment Share on other sites More sharing options...
chaseman Posted February 19, 2011 Author Share Posted February 19, 2011 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. EDIT: just tried it out, it works, THANKS. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.