Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8899503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:52:22+00:00 2026-06-15T00:52:22+00:00

I have two pages: one.php <?php if($_POST && $_POST[‘captcha’] == ‘thisisrandom’){ echo ‘KEY =

  • 0

I have two pages:

one.php

<?php if($_POST && $_POST['captcha'] == 'thisisrandom'){
    echo 'KEY = ' . uniqid();
} ?>
<form action="one.php" method="POST">
    NAME: <input type="text" name="name"> <br />
    CAPTCHA: <input type="text" name="captcha"> <br />

    <input type="submit">
</form>

two.php

<?php
function get_web_page($url)
{
        //echo "curl:url<pre>".$url."</pre><BR>";
    $options = array(
        CURLOPT_RETURNTRANSFER => true,     // return web page
        CURLOPT_HEADER         => false,    // don't return headers
        CURLOPT_FOLLOWLOCATION => true,     // follow redirects
        CURLOPT_ENCODING       => "",       // handle all encodings
        CURLOPT_USERAGENT      => "spider", // who am i
        CURLOPT_AUTOREFERER    => true,     // set referer on redirect
        CURLOPT_CONNECTTIMEOUT => 15,      // timeout on connect
        CURLOPT_TIMEOUT        => 15,      // timeout on response
        CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects

    );

    $ch      = curl_init($url);
    curl_setopt_array( $ch, $options );
    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch,CURLINFO_EFFECTIVE_URL );
    curl_close( $ch );

    $header['errno']   = $err;
    $header['errmsg']  = $errmsg;

    //change errmsg here to errno
    if ($errmsg)
    {
        echo "CURL:".$errmsg."<BR>";
    }
    return $content;
}
print_r(get_web_page('http://localhost/one.php'));
?>

and i open page two.php. This show me form from one.php. This is ok, but if i submit form then this redirect me to one.php. How can i fill in this form on page two.php, submit form and receive data on page two.php from one.php without redirect?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:52:23+00:00Added an answer on June 15, 2026 at 12:52 am

    You can make an AJAX Post call via Jquery to prevent redirecting when form is submitted.

    First remove action attribute from form element. HTML should look like this:

    <form method="POST">
        <label for="name">NAME:</label><input type="text" name="name" />
        <label for="captcha">CAPTCHA:</label><input type="text" name="captcha" />
        <input type="submit" />
    </form>
    

    Second, listen form submit button in one.php and make ajax post call when it is clicked. You can use jquery serialize function to create a data set from input values. And as one.php and two.php are not on the same domain, you should use jquery getjson option to get data.

    $(document).ready(function() {
        $('form input[type=submit]').click(function(event) {
            event.preventDefault();
            var formData = $(this).closest('form').serialize();
            $.ajax({
                    type: 'POST',
                    url: 'one.php',
                    data: formData,
                    dataType: 'json',
                    success: function(data) {
                       // do your work here
                    }
                });
         });
    });
    

    As the last thing to do, you need to format your php output by using php function json_encode. So one.php should look like this:

    <?php if($_POST && $_POST['captcha'] == 'thisisrandom'){
        $arr["key"]= "KEY";
        $arr["value"]= uniqid();
        echo json_encode($arr);
    } ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two php pages. Page 1 contains one form which i submitted with
I have two pages. First one we open with $_POST variables in its url,
For example, I have created two pages and two MySQL tables. Index.php & citys.php
I have two pages that inherit from one master page, First.aspx or second.aspx. Navigation
I have two pages, one that edits user information, and one that edits information
I'm trying to build a portal in which i have two pages , one
On one PHP server I have two files. One file (the name is first.php)
In one page I have two form for search: <form class=search-panel method=post action= onsubmit=return
I have two pages, one posts value to another, then it makes a mysql
I have two pages, one sending a file_get_contents request: $postdata = http_build_query( array('install' =>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.