Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Redirect php form after form is submitted

Hi team below code is the form for my website how can I send users to another page after form is submitted I have created that page as well : "https://unicent.in/nagole-admissions-open/Thankyou.html"

can you quickly share some easy method to achieve the output

            
            <!--Course Form-->
            <div class="course-form">
                <!--Default Form-->
                <div class="default-form">
                    <form method="post" action="contact-detail.php">
                        <input type="hidden" name="contactform" value="2">
                        <div class="row clearfix">
                        
                            <!--Column-->
                            <div class="column col-md-9 col-sm-12 col-xs-12">
                                <div class="row clearfix">
                                    <!--Form Group-->
                                     <div class="form-group col-md-4 col-sm-6 col-xs-12">
                                        <input type="text" name="name" value="" placeholder="Enter Name*" required>
                                    </div>
                                     <div class="form-group col-md-4 col-sm-6 col-xs-12">
                                        <input type="email" name="email" value="" placeholder="Email Address*" required>
                                    </div>
                                
                                    <!--Form Group-->
                                    <div class="form-group col-md-4 col-sm-6 col-xs-12">
                                        <input type="text" name="mobile" value="" placeholder="Contact Number*" required>
                                    </div>
                                </div>
                            </div>
                            
                            <!--Column-->
                            <div class="column col-md-3 col-sm-12 col-xs-12">
                            
                                <!--Form Group-->
                                <div class="form-group text-right">
                                    <button type="submit" name="submit" class="theme-btn btn-style-one">Submit</button>
                                </div>
                                
                            </div>
                            
                            
                            <?php if (isset($_SESSION['msg2'])) { ?>
                        
                                    <div class="row" style="margin-top: 20px;">
                                        <div class="col-lg-12" style="text-align: center;">
                                            <div class="alert alert-success"><?= $_SESSION['msg2'] ?></div>
                                        </div>
                                    </div> 
                                <?php 
                                unset($_SESSION['msg2']);
                                } ?>
                            
                        </div>
                    </form>
                </div>
            </div>
            
        </div>
    </section>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In the contact-detail.php handler, you can add the following line to redirect using the header function

if( $_SERVER['REQUEST_METHOD'] == 'POST'){
 // do some thing with form...


 // redirect
 header('Location: http://www.example.com/');

}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading