Issue
i have a form in php which i created like a calculator, i have used angular js to display the user entered value on the display, which i designed like below:
<?php
if(isset($_POST['entering'])) {
header("Location: https://www.google.com");
exit();
} else {
$msg="Something Went Wrong. Please try again.";
}
?>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<div class='container'>
<div class='ct-inner'>
<!-- Project HTML Below -->
<div ng-app="" class='calculator'>
<div class='inner'>
<div class='innerIn'>
<div style="height:49px;" class='screen active'>
<div class='output'> {{name}}</div>
<div class='screen-layer'></div>
</div>
<form method="post" action="">
<div class='controls'>
<div style="margin-top:5%;" class="form__group">
<input ng-model="name" type="password" class="form__input" id="name" placeholder="Password" required="" maxlength="6" />
</div>
<div style="margin-left:35%; margin-top:1%;" class='control-pad operator-pad1'>
<input type="button" class='button med oper' name="entering" value="ENTER">
</div>
</div>
</form>
</div>
<!-- Inner in End -->
</div>
</div>
</div>
</div>
this is my whole code, when i am trying to submit the form entering values its not going to different page after submission, can anyone please tell me what could be wrong here, thanks in advance
Solution
From the Docs:
Since the role of forms in client-side AngularJS applications is different than in classical roundtrip apps, it is desirable for the browser not to translate the form submission into a full page reload that sends the data to the server. Instead some javascript logic should be triggered to handle the form submission in an application-specific way.
For this reason, AngularJS prevents the default action (form submission to the server) unless the
<form>
element has an action attribute specified.You can use one of the following two ways to specify what javascript method should be called when a form is submitted:
For more information, see
Answered By – georgeawg
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0