Good evening guys! I needed help with the alert (); , I want to display on the index.html page, a alert (); showing that the data was inserted correctly, reading some posts in the forum, gave the idea of the index.php (where it is processed data) save the message in a $ _ SESSION and pull JS from the HTML $ _ SESSION value. I tested the idea and the result was this:
PHP Code:
$_SESSION['registro'] = "Seu gasto foi inserido corretamente!!";
header("location: index.html");
HTML code
<script>alert(".$_SESSION['registro'];.");</script>
Remembering that I tried to change the "" to "", both the $ _SESSION and the alert (); "
The result was:
Doubtis...Whereistheerror?IfyouhavenoerrorwhatotheralternativecanIusetodisplaythisalertaftertheinsertmadebyindex.php?
[RESOLVED]
Ichangedmyindex.htmltoindex.phpthenaddedthefollowinglineofcode:
<script>alert('<?phpsession_start();if($_SESSION['registro']!=null){echo$_SESSION['registro'];}?>');</script>
ImportanttostressthatIwasnotputtingsession_start();
AndonmydatauploadpageIaddedthevalueof$_SESSION
session_start();if($_SESSION['registro']==null){$_SESSION['registro']="Registro cadastro com sucesso !";
}
header("location: index.php");