Jump to content

help with this form button as link


searls03

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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";

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>";

}
?>

Link to comment
Share on other sites

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");

...
?>

Link to comment
Share on other sites

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>";

}
?>

Link to comment
Share on other sites

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

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.