Reputation: 1477
In my form im trying to check if my url have a property called email, and if haves show me the input email in the form with the value already filled, and in case it doesnt give a input email but empty. But im getting "undefined index: email".
My blade html is:
<?php
$email = $_GET['email'];
?>
@if(isset($email))
<div class="form-group">
<label>Email:</label>
<input class="form-control" type="email" name="email_source" value="{{$email}}">
</div>
@else
<div class="form-group">
<label>Email:</label>
<input type="email" name="email_source" value="">
</div>
@endif
In my url there cand have 2 situations:
http://domain.com/surveys/9/show (no email)
and
http://domain.com/surveys/9/[email protected] (with email)
Someone have a idea what im doing wrong?
Upvotes: 0
Views: 1577
Reputation: 1182
$email = isset($_GET["email"]) ? $_GET["email"] : NULL;
What it does:
Then proceed to check if $email is set or not.
Straight calling $email = $_GET["email"] will set the variable as an empty string if $_GET["email"] is empty.
Upvotes: 2