Asked  7 Months ago    Answers:  5   Viewed   39 times

Do you have any suggestions with my problem. I need to use get and post at the same time. Get because I need to output what the user has typed. And post because I need to access the mysql database in relation to that input. It looks something like this:

<form name="x" method="get" action="x.php">
<input name="year" type="text">

<select name="general" id="general">
        <font size="3">
        <option value="YEAR">Year</option>


This will output the contents of mysql depending on what the user will check:

<form name="y" method="post" action"y.php">
<input name="fname" type="checkbox">

And the form action of those two combined will look something like this:


               if($_POST['general'] == 'YEAR'){
                   <?php echo $_GET["year"]; ?>
            $result2 = mysql_query("SELECT * FROM student
    WHERE student.YEAR='$syear'");
    <table border='1'>

                    <?php if ( $ShowLastName ) { ?><th>LASTNAME</th><?php } ?>
                    <?php if ( $ShowFirstName ) { ?><th>FIRSTNAME</th><?php } ?>

    <?php while ( $row = mysql_fetch_array($result2) ) {
        if (!$result2)  { 

                    <td><?php echo $row['IDNO']?> </td>
                    <td><?php echo $row['YEAR'] ?> </td>
     <?php if ( $ShowLastName ) { echo('<td>'.$row['LASTNAME'].'</td>'); } ?></td>
                    <?php if ( $ShowFirstName ) { echo('<td>'.$row['FIRSTNAME'].'</td>'); } ?>

I really get lots of undefined errors when I do this. What can you recommend that I should do in order to get the value inputted by the user together with the mysql data.



You can only have one verb (POST, GET, PUT, ...) when doing an HTTP Request. However, you can do

<form name="y" method="post" action="y.php?foo=bar">

and then PHP will populate $_GET['foo'] as well, although the sent Request was POST'ed.

However, your problem seems to be much more that you are trying to send two forms at once, directed at two different scripts. That is impossible within one Request.

Wednesday, March 31, 2021
answered 7 Months ago

you can't print the result from mysqli_query, it is mysqli_resource and for dumping the error you need to change mysql_error() to mysqli_error()

$username = "bob";
$db = mysqli_connect("localhost", "username", "password", "user_data");
$sql1 = "select id from user_information where username='$username'";
$result = mysqli_query($db, $sql1) or die(mysqli_error());
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { 
    echo $row['id'].'<br>'; 
Saturday, May 29, 2021
answered 5 Months ago

yo need create the user "pma" in mysql or change this lines(user and password for mysql):

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma'; 
$cfg['Servers'][$i]['controlpass'] = '';

Linux: /etc/phpmyadmin/

Tuesday, July 13, 2021
answered 4 Months ago

You'll need to pass a boolean true as the optional fourth argument to mysql_connect(). See PHP's mysql_connect() documentation for more info.

Monday, August 2, 2021
answered 3 Months ago

You can use get and post at the same time, but you shouldn't. If you want to continue to send the ID this is as simple as:

<form ...
   <input type="submit" ...
   <input type="hidden" name="id"
      value="<?php echo htmlspecialchars($_GET['id'], ENT_QUOTES); ?>" />
Saturday, August 7, 2021
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :