Jump to content

Unable to retrieve ID number using $_GET


genzedu777

Recommended Posts

Hi guys,

 

Currently I am editing profiles online and get it updated in my database.

 

And when user has successfully updated his/her profile, they will be directed to a link

echo '<p>Your profile has been successfully updated. Would you like to <a href="viewprofile.php?tutor_id=' . $_GET[$row['tutor_id']] . '">view your profile</a>?</p>';

 

As you can see, I have set tutor_id=' . $_GET[$row['tutor_id']] . ', which I personally know is incorrect to code it in this manner. May I know how do I code in a way where I can achieve something like this...

www.abc.com/viewprofile?tutor_id=12343

 

 

The value which currently I receive is www.abc.com/viewprofile?tutor_id='blank'

<?php
if (!$error) {
      if (!empty($tutor_id) && !empty($name) && !empty($nric) && !empty($dob_day) && !empty($dob_mth) && !empty($dob_year) && !empty($gender)) {
        
	// Only set the picture column if there is a new picture
	if (!empty($new_picture)) {
		$query = "UPDATE tutor_profile SET name = '$name', nric = '$nric', dob_day = '$dob_day', dob_mth = '$dob_mth', dob_year = '$dob_year',  
		gender = '$gender', picture = '$new_picture' WHERE tutor_id = '$tutor_id' ";
	}
	else {
          $query = "UPDATE tutor_profile SET name = '$name', nric = '$nric', dob_day = '$dob_day', dob_mth = '$dob_mth', dob_year = '$dob_year',  
	  gender = '$gender' WHERE tutor_id = '$tutor_id' ";
        }

	mysqli_query($dbc, $query)
	or die(mysqli_error($dbc));

        // Confirm success with the user
        echo '<p>Your profile has been successfully updated. Would you like to <a href="viewprofile.php?tutor_id=' . $_GET['tutor_id'] . '">view your profile</a>?</p>';

        mysqli_close($dbc);
        exit();
?>

Link to comment
https://forums.phpfreaks.com/topic/226765-unable-to-retrieve-id-number-using-_get/
Share on other sites

Hi guys,

 

Currently I am editing profiles online and get it updated in my database.

 

And when user has successfully updated his/her profile, they will be directed to a link

echo '<p>Your profile has been successfully updated. Would you like to <a href="viewprofile.php?tutor_id=' . $_GET[$row['tutor_id']] . '">view your profile</a>?</p>';

 

As you can see, I have set tutor_id=' . $_GET[$row['tutor_id']] . ', which I personally know is incorrect to code it in this manner. May I know how do I code in a way where I can achieve something like this...

www.abc.com/viewprofile?tutor_id=12343

 

 

The value which currently I receive is www.abc.com/viewprofile?tutor_id='blank'

<?php
if (!$error) {
      if (!empty($tutor_id) && !empty($name) && !empty($nric) && !empty($dob_day) && !empty($dob_mth) && !empty($dob_year) && !empty($gender)) {
        
	// Only set the picture column if there is a new picture
	if (!empty($new_picture)) {
		$query = "UPDATE tutor_profile SET name = '$name', nric = '$nric', dob_day = '$dob_day', dob_mth = '$dob_mth', dob_year = '$dob_year',  
		gender = '$gender', picture = '$new_picture' WHERE tutor_id = '$tutor_id' ";
	}
	else {
          $query = "UPDATE tutor_profile SET name = '$name', nric = '$nric', dob_day = '$dob_day', dob_mth = '$dob_mth', dob_year = '$dob_year',  
	  gender = '$gender' WHERE tutor_id = '$tutor_id' ";
        }

	mysqli_query($dbc, $query)
	or die(mysqli_error($dbc));

        // Confirm success with the user
        echo '<p>Your profile has been successfully updated. Would you like to <a href="viewprofile.php?tutor_id=' . $_GET['tutor_id'] . '">view your profile</a>?</p>';

        mysqli_close($dbc);
        exit();
?>

 

your $tutor_id  doesn't get a value same is for $_GET['tutor_id'] if i look at the script above. so the whole script that starts with

if (!empty($tutor_id)......etc will not be executed.

Also the echo is outside the if statement, so it's not a confirmation of succes it's just an echo.

 

Don't you have some more code besides the above?

Archived

This topic is now archived and is closed to further replies.

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