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 8769839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:26:18+00:00 2026-06-13T17:26:18+00:00

I try to send a variable using jquery and ajax to php script. Then

  • 0

I try to send a variable using jquery and ajax to php script. Then I want to use that variable in creating a file name but it fails. The file name is always “0” and does not locate at the dir “redirect”.

Here is the code:

Ajax:

    var pageName=$('#movie').val();

    $.ajax({
        type: "POST",
        url: "phpstuff.php",
        data: { pageName: 'pageName'},
        cache: false,
        success: function()
            {
                alert(pageName);
            }
    });

the “pageName” variable gets the value from an input box with an id “movie”

The php file

function createPage ($newPage){

$file=fopen("redirect/"+$newPage+".php","w") or exit("Fail to create the page");
$data = "some text I want to be in a file";
fwrite ($file, $data);
fclose($file);
}

$newPage = $_POST["pageName"];
createPage($newPage);

I have searched the net for hours and still can’t fix the problem.

  • 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-13T17:26:19+00:00Added an answer on June 13, 2026 at 5:26 pm

    String concatenation should be done with .:

    "redirect/" . $newPage . ".php"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Jquery, Ajax and PHP to try and send a variable to be
i try to send some data to my php file from ajax , but
I try to send json array to ajax (from PHP to jQuery) in my
I am uploading a file using PHP and want to return the file name
i try to send my datas to php with ajax but there's strange mistake.
I am using a PHP script to send push notifications to my device. Here
i try to send data to my php scripts but i think i miss
I try to send a sms using next code, but recipient gets my message
I'm using variable passing through a URL (ie .derp.html?name=derp?lname=herp) to a popup (which uses
Currently users can search a database using php and ajax with the results shown

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.