Jump to content

Recommended Posts

I have a form that is filled in and each part that has something done to it i want added to a database on my server, for that user.

I have a onchange=update() in my form and this would then call the script to update the database.

is this possible.

or is there another way i can do this.

i tried to use in the update.js file


function update()
{
<?
echo("hello");
?>
}

just to see if anything happen, and it did not.

how can i execute php while in a js file?

is there another way to do this?

thanks you in advance for your help.


Jason
Link to comment
https://forums.phpfreaks.com/topic/3636-execute-php-from-javascript/
Share on other sites

php is executed on the server and then the code that is outputted by the php code, is added to your site's HTML. After a user views your website, the php has already been executed and the output writen to your site. If you need to pass information to a php file after the user has viewed your site you can set up a hidden or visible textbox form with HTML, and send the POST values (or the values of each form element after the user has 'posted' the form) to another php file.

Set your form "action" to the next php file you want to pass the variables to, and then you can use $_POST['html form element name'] THis is your form element value.
my page has lots of options and i want to be sure that the selection are kept in case they lose their connection of what ever.

each person has a login name and password.

while they make their selection i want the database updated on each change, so that they can come back later to finish off, without having to full out everything from the start again.

how else can i do this?

Thanks

Jason
Use javascript to store the values in a cookie.

[a href=\"http://www.w3schools.com/js/js_cookies.asp\" target=\"_blank\"]http://www.w3schools.com/js/js_cookies.asp[/a]

Then when they come back to the site, you should be able to retrieve the vars in either php or javascript.
Hi,

Thanks for a quick response.

Yes i know i could use cookies, but want to make this as streamlined as possible.

i know as i do myself, disable cookies from being stored on my pc, this is why i would like to have it stored in the database.

how else can i do this?


Jason
[!--quoteo(post=349702:date=Feb 27 2006, 12:00 AM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Feb 27 2006, 12:00 AM) [snapback]349702[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Your only other option for storing each field as they are entered is ajax.
[/quote]

your say ajax, but what am i looking for?

i have posted my question there.

thanks

Jason
[!--quoteo(post=349788:date=Feb 27 2006, 09:53 AM:name=tim_perrett)--][div class=\'quotetop\']QUOTE(tim_perrett @ Feb 27 2006, 09:53 AM) [snapback]349788[/snapback][/div][div class=\'quotemain\'][!--quotec--]
AJAX it is, thats the only way you will do that....

www.ajaxfreaks.com

Tim Perrett
[/quote]

ajax is a forum with some help pages with scripts.
what an i actually looking for on this site.
a link would be helpfull to an idiot like me.
i am not very bright!
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.