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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:47:05+00:00 2026-06-14T07:47:05+00:00

As per requirement, I want to allow the user to write to session when

  • 0

As per requirement, I want to allow the user to write to session when submitting a form but without reloading the page, this is what i have done so far:

Javascript function:

$(function() {
$("#body").submit(function(){
var name = $("#player_name").val();
var dataString = 'player_name='+ name
alert (dataString);return false; 
   $.ajax({
      type: "POST",
      url: "session_update.php",
      data: dataString,
      success: function(){
        $('#body').html("<div id='message'></div>");  
        $('#message').html("<h2>Logged in!</h2>");
      });
   }
});
   return false;
});

My form im trying to submit:

    <div class="body">
<div class="home" id="home" style="width:100%">
    <form action="" name="login">
    USERNAME: <input type="text" id="player_name" name="player_name"/>
          <br>
      <input type="submit" name="submit" class="button" id="submit_btn" value="Send" />
         </form>
<? echo "value=". $_SESSION['player_name'];?>
</div>

the php file its sending the data to:

<?php
start_session();
$_SESSION['player_name']= $_POST["player_name"];
?>

any advice your be greatly appreciated, fairly new to this side of coding so it could be something obvious thats causing it but i just cant see it.

For more information let me know.

UPDATE

Console showing
?player_name=User&send:75

  • 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-14T07:47:07+00:00Added an answer on June 14, 2026 at 7:47 am

    You need to use session_start(); not start_session()

    Always ensure that you test your PHP scripts manually, not just pointing to the page with ajax. Go to it and make sure it works. 🙂

    If you tested this (assuming error_reporting is on), you will have received an error stating that you are trying to call an undefined function.

    UPDATE

    In addition to the session_start() issue, you have may other problems in your code.

    First step is to debug using either console.log('hello'); or alert('hello'). Bind these actions to the form submit event and this will tell you whether or not the submit function is being called.

    Once you have done this then you can continue to debug the rest 🙂

    UPDATE 2

    From looking at your jQuery, it would appear that you are attaching the submit event to the wrong element in the DOM. You need to attach it to the form, not a div. Like so:

    $(function() {
        $("#form").submit(function(){
            var name = $("#player_name").val();
            var dataString = 'player_name='+ name
            $.ajax({
              type: "POST",
              url: "session_update.php",
              data: dataString,
              success: function(){
                $('#body').html("<div id='message'></div>");  
                $('#message').html("<h2>Logged in!</h2>");
              });
            }
        });
    });
    

    and

    <div class="body">
        <div class="home" id="home" style="width:100%">
            <form id="form" action="" name="login">
                USERNAME:<input type="text" id="player_name" name="player_name"/><br>
                <input type="submit" name="submit" class="button" id="submit_btn" value="Send" />
            </form>
            <? echo "value=". $_SESSION['player_name'];?>
        </div>
    

    TIP: Use CSS to space elements, don’t use br tags. Just my opinion 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a button, i want to show to user in page load normal
As per requirement, I want to update an existing tipsy title, but it doesn't
I want to append font style and type in textarea as per user requirement.
As per client requirement i want to send crash Report when App get crash.
I have deployed an application on the IIS server, as per my requirement i
As per requirement I disabled all validation controls in page on PageLoad event in
As per the requirement i have to create xhtml dynamically as described below <ul
I have an requirement as per which I have to call an existing java
My page have multiple dialog boxes. I've separate div sections defined for it. Per
i have developed a simple php contact form, that's working fine, but i am

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.