Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

keroherox20's avatar

Redirect with Session flash data not showing in blade

Hello

i have problem with success -> Result i can't see Result after Redirect Success

Home.blade.php

<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>

	<center>
	<form method="POST" action="{{ route ('imei') }}" style="margin-top:5%">
        @csrf
		<p><input type="text" style="padding: 15px 10px 10px; font-family: 'Source Sans Pro',arial,sans-serif; border: 1px solid #cecece; color: black;box-sizing: border-box; width: 50%; max-width: 500px;" name="imei" autocomplete="off" maxlength="50" placeholder="Write here IMEI or SN"></p>
		<select name="service" id="service" style="padding: 15px 10px 10px; font-family: 'Source Sans Pro',arial,sans-serif; border: 1px solid #cecece; color: black;box-sizing: border-box; width: 50%; max-width: 500px;">
			<option value="0" selected="selected">PLEASE CHOOSE CHECKER</option>
			<optgroup label="iPHONE SERVICES">
				<option value="0.01">1.10 - APPLE SOLD BY & COVERAGE &#x26A1;</option>
			</optgroup>
		</select>
		<br /><br />
		<button onClick="this.form.submit(); this.disabled=true; this.value='Please Wait'; " type="submit" style="background-color: #2ABCA7; padding: 12px 45px; -ms-border-radius: 5px; -o-border-radius: 5px; border-radius: 5px; border: 1px solid #2ABCA7;-webkit-transition: .5s; transition: .5s; display: inline-block; cursor: pointer; width: 20%; max-width: 200px; color: #fff;">Submit</button>
	</form>

</center>


  <script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>

 	@if(Session::has('success'))
        
	  	<script type="text/javascript">
	  		Swal.fire({
			  position: 'center',
			  icon: 'success',
			  title: "{!! Session::get('success') !!}",
			  showConfirmButton: false,
			  timer: 2500
			})
	  	</script>

  	@elseif(Session::has('error'))
        
        <script type="text/javascript">
	  		Swal.fire({
			  position: 'center',
			  icon: 'error',
			  title: "{!! Session::get('error') !!}",
			  showConfirmButton: false,
			  timer: 2500
			})
	  	</script>

  	@endif


</body>
</html>

Controller

public function imeiSubmit() {


 
    $format = "html"; // Display result in JSON or HTML format
     $imei = $_POST['imei']; // IMEI or SERIAL Number
     $apiKey ='veCwe-bzgzE-JP9NE-ZHEaS-PxFuq-rnmLz';
     $service = $_POST['service']; // Service ID

     $balanceUrl = 'https://alpha.imeicheck.com/api/php-api/balance?key='.$apiKey;

     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $balanceUrl);
     curl_setopt($ch, CURLOPT_POST, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
     curl_setopt($ch, CURLOPT_TIMEOUT, 60);

     $balance = curl_exec($ch);
     curl_close($ch);

     if ($balance == '{"balance":"0.00"}') {
        return redirect()->back()->with('error', 'balance 0.00!');
     }
     
     if($service != 'demo') {
      $service = preg_replace("/[^0-9]+/", "", $service);
     }

     if(strlen($service) > 4 || $service > 250)
    {
        return redirect()->back()->with('error', 'Service ID is Wrong!');
    }

    if(!filter_var($imei, FILTER_VALIDATE_EMAIL))
    {
        if(strlen($imei) < "11" || strlen($imei) > "15")
        {
            return redirect()->back()->with('error', 'IMEI or SN is Wrong!');
        }
    }
        
         $curl = curl_init ("https://alpha.imeicheck.com/api/php-api/create?format='.$format.'&key='.$apiKey.'&service='.$service.'&imei='.$imei");
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
         curl_setopt($curl, CURLOPT_TIMEOUT, 60);
         $result = curl_exec($curl);
         curl_close($curl);

         return redirect()->back()->with('success', PHP_EOL.$result);
        // // echo PHP_EOL."<br/><br/>".PHP_EOL.$result; // Here the result is printed

         
    }

any one can help me for that ? or another solution

0 likes
3 replies
Snapey's avatar

errors in browser console?

does the page code include your success block? (view page source)

Snapey's avatar

instead

return redirect()->back()->with(['success' => $result]);

Please or to participate in this conversation.