Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

isset($_GET['variable']) not working?

Tags:

php

This function is not working for me. I think it is isset($_GET['success']) that's not working but I'm really not sure. the problem is it doesn't print anything ever. And without if(isset($_GET['success'])) it only prints "username taken" Please help?

<?php
if(isset($_GET['success'])) {
$success=$_GET['success'];
if($success=='yes') {
echo "<center><font color='red'>Comment Posted!</font></center>";
}
else {
echo "<center><font color='red'>Username taken!</font></center>";
}
}
?>
like image 835
user838189 Avatar asked Mar 04 '26 21:03

user838189


1 Answers

What kind of output are you getting from this? Are you passing the GET method correctly? the URL should have page_name.php?success=yes in it. If you're not getting anything and you want success to be only set if it is true perhaps this would be better.

<?php 
if(isset($_GET['success']) && $_GET['success']=='yes') 
{
     echo "<center><font color='red'>Comment Posted!</font></center>";
}
else 
{
     echo "<center><font color='red'>Username taken!</font></center>";
}
?>
like image 78
Jeremy Avatar answered Mar 06 '26 11:03

Jeremy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!