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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:33:05+00:00 2026-06-06T15:33:05+00:00

Wondering if someone could help me. I have next to no knowledge with Ajax,

  • 0

Wondering if someone could help me. I have next to no knowledge with Ajax, and after many attempts at trying to pass my User1_id and Text through to my insert.php I’ve had no luck with inserting the data I want to my database.

As my profile.php and insert.php stands, the form submits to the database, but when the user submits the form it navigates to the insert.php and would rather have the Ajax send the data and stay on the Profile.php at all times, I feel this is a much better approach when creating such functions.

I’m wondering if someone can guide me in the right direction on how I’d go about doing this.

Profile.php Form

<form id="FormId" action="" method="get">
    <input type="hidden" value="<? echo $user1_id ?>">
        <textarea placeholder="Whats New??" id="FormId" name="status"></textarea>
            <input type="submit" name="Submit" value="Submit">
            </form>

Insert.php

    <?
    session_start();
    ini_set('display_errors',1);
    error_reporting(E_ALL|E_STRICT);
    include "db_connect.php";
    if (isset($_GET['status']))  {
         $status = $_GET['status'];
    }
    $user1_id=$_SESSION['id'];



if ($_GET['status']) {
$query = mysql_query("INSERT INTO feed (status,user1_id) VALUES ('$status', '$user1_id')")  or die (mysql_error());
if($query){
    echo "Posted Into Database";
}

exit();
}
?> 

I know I need something similiar to this.. But I think I’m stuck more on the var/data part.

$("form#myFormId").submit(function() {
    var mydata = $("form#myFormId").serialize();
    alert(mydata); // it's only for test
    $.ajax({
        type: "GET",
        url: "insert.php",
        data: mydata,
        success: function(response, textStatus, xhr) {
            alert("success");
        },
        error: function(xhr, textStatus, errorThrown) {
            alert("error");
        }
    });
    return false;
});

But don’t know how to go about it.

Any guidence is appreciated. Not asking anyone to write the code out for me. But good direction is welcomed.

Thanks.

  • 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-06T15:33:06+00:00Added an answer on June 6, 2026 at 3:33 pm

    Just like to say thank you to both of you for your time and help. I re-wrote the code and have now got it working.

    Here is the final code
    PROFILE.PHP/JS

    <script type="text/javascript">
    
    function createstatus(content){
    $.post("insert.php", { user1_id: content } );
    refreshstream();
    }
    
    function createwallpost(content,user1_id){
    
    $.ajax({
       type: "POST",
       url: "insert.php",
       data: "status="+content+"&user1_id="+user1_id,
       success: function(){
         document.location = document.location;
       }
     });
    
    }
    </script>
    
        <form action="insert.php" method="POST" target="ifr1" class="form_statusinput">
            <input type="hidden" name="user1_id" value="<?php echo $user1_id ?>">
            <input type="text" name="status" id="status" class="homescreen_status_input" placeholder="Say something">
            <iframe name="ifr1" id="ifr1" style="display:none;"></iframe>
        </form>
    

    INSERT.PHP

    <?
    session_start();
    include "db_connect.php";
    if (isset($_POST['status']))  {
         $status = $_POST['status'];
    }
    
    $user1_id = $_POST['user1_id'];
    
    
    if ($_POST['status']) {
    $query = mysql_query("INSERT INTO feed (status,user1_id) VALUES ('$status', '$user1_id')")  or die (mysql_error());
    if($query){
        echo "Posted Into Database";
    }
    
    exit();
    } 
    
    
    ?> 
    

    I decided to go with post instead of the GET method, as I feel its securer and passes more information through smoothly.
    Thanks again.

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

Sidebar

Related Questions

I was wondering if someone could help me with this. I have defined my
I was wondering if someone could help with this: I have a series of
I was wondering if someone could help me. Im trying to integrate some code
Im wondering if someone could help me. I have hundreds of people uploading images
I was wondering if someone could help me. I have started using version control
I was wondering if someone could help me with a simple question? i have
I have reached a problem and was wondering if someone could help me please.
I was wondering if someone could help me. Suppose I have some classes as
I have an SQL problem i was wondering if someone could help me out.
Im wondering if someone could help me .... I have 2 images, and i

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.