searls03 Posted March 17, 2011 Share Posted March 17, 2011 Ok, I need this button here to be a link to /admin.php?edit&id=$userid. I cant get anything after the edit to work. please help: echo "<form action='admin.php?edit&id=' method='get'><INPUT TYPE='submit' name='submit' VALUE='Edit'></form>\n"; echo "</td><td>"; I am pretty sure that this is not complete, but I cant seem to figure it out for some reason... Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/ Share on other sites More sharing options...
Eyewash01 Posted March 17, 2011 Share Posted March 17, 2011 Um, well you haven't set the get variables to anything. Try something more like this: echo '<form action="admin.php?edit=1&id='.$userid.'" method="get">'; When you have just one GET variable, for example, login.php?logout, you can definitely just have the variable without a value assignment, and although I've never tried it with more than one, that is probably you're problem. Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1188927 Share on other sites More sharing options...
searls03 Posted March 18, 2011 Author Share Posted March 18, 2011 it has to be that exact address, cant change it.....the get value is what I was hoping I could get help with....... Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1188974 Share on other sites More sharing options...
lastkarrde Posted March 18, 2011 Share Posted March 18, 2011 Your not passing any ID to admin.php?edit&id= in your form code. How does admin.php know which userid to update? Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1188988 Share on other sites More sharing options...
searls03 Posted March 18, 2011 Author Share Posted March 18, 2011 It grabs it from $userid....... Could you just help me make the code piece please and I can worry about where all it comes from and I will ask if I need help? Sorry if this sounds mean, but that's really all I need right now..... Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1188990 Share on other sites More sharing options...
Eyewash01 Posted March 18, 2011 Share Posted March 18, 2011 I think you need to go back and look at a tutorial for using GET and POST variables - as both me and lastkarrde have pointed out, you are not actually including the variable $userid in your original code on the address in the form action. Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1189028 Share on other sites More sharing options...
searls03 Posted March 20, 2011 Author Share Posted March 20, 2011 ok so i have this code for a new button as link.......it goes to proper page but doesnt insert id or get id.........help please.echo " <form action='registration.php' method='get'><input type='hidden' name='eventid' value='{$row['eventid']}'><INPUT TYPE='submit' name='submit' VALUE='Register'></form>\n"; Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190011 Share on other sites More sharing options...
cyberRobot Posted March 21, 2011 Share Posted March 21, 2011 If you look at the source code for the HTML form, does the value attribute of "eventid" get set to the ID as expected? <input type='hidden' name='eventid' value='{$row['eventid']}'> Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190243 Share on other sites More sharing options...
searls03 Posted March 21, 2011 Author Share Posted March 21, 2011 I am pretty sure it does Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190276 Share on other sites More sharing options...
cyberRobot Posted March 21, 2011 Share Posted March 21, 2011 Do you know if the ID is getting passed to registration.php? echo $_GET['eventid'] If it doesn't display anything, the bug is likely on the page that displays the form. My guess would be the input value for eventid isn't getting populated. If registration.php is getting the ID value, it might be helpful if you post the code that doesn't seem to work for registration.php. Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190285 Share on other sites More sharing options...
PFMaBiSmAd Posted March 21, 2011 Share Posted March 21, 2011 I am pretty sure it does If you haven't actually checked at what point you have the expected data and at what point you don't, there's no point in wasting time trying to guess where the problem is. There could be a half-dozen different reasons your code doesn't work and you must narrow down the problem by finding out where your code and data is doing what you expect and where it is not. Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190290 Share on other sites More sharing options...
searls03 Posted March 21, 2011 Author Share Posted March 21, 2011 Ok I will double check in a bit, I am pretty sure it is, but i could be wrong............. Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190294 Share on other sites More sharing options...
searls03 Posted March 21, 2011 Author Share Posted March 21, 2011 I believe it is here, but I could be wrong...... <?php if (isset($_GET['eventid'])) { include('connect1.php'); $sql = mysql_query("SELECT * FROM Registration WHERE eventid='$eventid' LIMIT 1"); $result = mysqli_query($dbcon, $query) or die('error getting data'); echo "<table>"; while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo "<tr><td>"; echo "<form action='registration.php' method='get'><input type='hidden' name='eventid' value='{$row['eventid']}'><INPUT TYPE='submit' name='submit' VALUE='Register'></form>\n"; echo "</td></tr>"; } echo "</table>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190415 Share on other sites More sharing options...
cyberRobot Posted March 21, 2011 Share Posted March 21, 2011 It looks like you're using two different variables for the event ID. I would imagine you need to use the $_GET version in the SQL query, unless you've define $eventid somewhere else in the script. <?php .. if (isset($_GET['eventid'])) { include('connect1.php'); $sql = mysql_query("SELECT * FROM Registration WHERE eventid='$eventid' LIMIT 1"); ... ?> Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190419 Share on other sites More sharing options...
searls03 Posted March 21, 2011 Author Share Posted March 21, 2011 still not working..... <?php if (isset($_GET['eventid'])) { include('connect1.php'); $sql = mysql_query("SELECT * FROM Registration WHERE eventid=".$_GET['eventid']." LIMIT 1"); $result = mysqli_query($dbcon, $query) or die('error getting data'); echo "<table>"; while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo "<tr><td>"; echo "<form action='registration.php' method='get'><input type='hidden' name='eventid' value='{$row['eventid']}'><INPUT TYPE='submit' name='submit' VALUE='Register'></form>\n"; echo "</td></tr>"; } echo "</table>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190424 Share on other sites More sharing options...
searls03 Posted March 22, 2011 Author Share Posted March 22, 2011 anybody? Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190696 Share on other sites More sharing options...
kenrbnsn Posted March 22, 2011 Share Posted March 22, 2011 You're mixing mysql & mysqli functions. You can't do that. Also since you're only expecting one record to be returned from the query you don't need the while loop and you should only ask for the fields you're going to use, not all of them: <?php if (isset($_GET['eventid'])) { include('connect1.php'); $sql = "SELECT eventid FROM Registration WHERE eventid=".$_GET['eventid']." LIMIT 1"); $result = mysqli_query($dbcon, $query) or die('error getting data'); echo "<table>"; $row = mysqli_fetch_array($result, MYSQLI_ASSOC)); echo "<tr><td>"; echo "<form action='registration.php' method='get'><input type='hidden' name='eventid' value='{$row['eventid']}'><INPUT TYPE='submit' name='submit' VALUE='Register'></form>\n"; echo "</td></tr>"; echo "</table>"; } ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190703 Share on other sites More sharing options...
aabid Posted March 22, 2011 Share Posted March 22, 2011 Posted by mistake eventually edited it to this.... Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190719 Share on other sites More sharing options...
cyberRobot Posted March 22, 2011 Share Posted March 22, 2011 I would imagine the mysqli_query needs to use the $sql variable and not $query: <?php ... $sql = "SELECT eventid FROM Registration WHERE eventid=".$_GET['eventid']." LIMIT 1"); $result = mysqli_query($dbcon, $sql) or die('error getting data'); ... ?> Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190791 Share on other sites More sharing options...
kenrbnsn Posted March 22, 2011 Share Posted March 22, 2011 Yes, I was half-asleep when I typed that. Ken Quote Link to comment https://forums.phpfreaks.com/topic/230956-help-with-this-form-button-as-link/#findComment-1190835 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.