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

  • Home
  • SEARCH
  • 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 8687251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:04:26+00:00 2026-06-12T23:04:26+00:00

I’ve been trying to get user input from a Javascript prompt into a PHP

  • 0

I’ve been trying to get user input from a Javascript prompt into a PHP function and have run into a lot a walls doing so. I am at a loss trying jQuery’s $.post method- as the PHP simply does not want to execute, not sure why.

Anyways, here is a gist of what I am doing at the moment:

1 A project and its data are loaded from a database- this info is displayed in a table.

2 All data in the table is editable via Javascript prompt(), the code I am using for this is below:

<div id="lvl3"><a href="" onclick="popupprompt(1); return false"><?php echo $fetchdata['name']; ?></a></div>

The above work as such: lvl3 is a tag for font styling; blank href to make it act as a link; popupprompt is the prompt function I made, it takes one argument, the ‘type’ or what is being edited (1 for project name, 2 for project description, ect); return false so the page doesn’t reload; php echo to display project data in the table.

3 Once the user clicks the object above- it executes a javascript function called popupprompt taking an argument of ‘type’, or what project info is being changed. the code for this function is below:

    function popupprompt(type) {
        switch(type)
    {
        case 1:
            var name = prompt("Project Name:", "");

            if (name != null && name != "")
            {
                //Change Project Name
                var getname = name;
                var gettype = type;

                $.post("edit.php", { type: gettype, name: getname });
            } else if (name == "") {
                senderror("Please enter a valid Project Name");
            } else {
                //Prompt canceled
                sendnotification('Canceled my ass!');
            }
            break;
        case 2:
                            //Description?
        case 3:
            //Version?
        case 4:
            //Release?
        default:
            alert("There was an error processing your request.");
            break;
    } }

Th issue I am having in this function is that nothing in edit.php is executed- and i haven’t the slightest clue why. Also, i’ve had to change the brackets around so it shows properly in the code box- so don’t mind those.

4 Anyways, now user input is posted to edit.php- which doesn’t work, but i’ll post it anyways:

    <?php
    $type = $_POST['type'];
    $name = $_POST['name'];

    switch($type) {
case 1:

    dbconnect();

    $urlext = geturlext();
    $authenticated = isauthenticated();

    if ($authenticated == false)
    {
        echo("<script>senderror('Access denied');</script>");
    } else {

        //Escape and trim input
        $input = trim($input);
        $input = mysql_real_escape_string($input);

        $update = "UPDATE 'projects' SET 'name' = '$input' WHERE 'name' = '$urlext'";
        $updatequery = mysql_query($update) or die(mysql_error());

        echo("<script>sendnotification('Project Name updated');</script>");
        }
    break;
    default:
    break;
    }
    ?>

Again had to move some brackets around. But anyways- this function is supposed to update the data in the database- however, it instead does nothing. I’ve placed alerts in the beginning and they are never called.

Anyways, long story short- if you know what i’m doing wrong please enlighten me, also, if there is a better way to do this- please let me know!

I appreciate all help,
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-12T23:04:27+00:00Added an answer on June 12, 2026 at 11:04 pm

    Figured it out after a good week of setting it aside. Took a long look at it in firebug, rooted out a typo that was causing most of my issues and also a MySQL syntax error.

    I don’t know why, but my custom error reporting system does not work when called from a file in this manner. It might be another thing i’m overlooking but firebug sure helped.

    Thanks to those who tried to help <3

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from

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.