Daney11 Posted April 24, 2007 Share Posted April 24, 2007 Hi guys. Ive created a in website mail system for my website, however i am not using a button for the submit. I am using normal text and javascript to submit form which works fine BUT in order to insert the information into the database im using if (isset($_POST[''])) { Now if i was using a button to submit it and had the name as submit i would enter submit into the post area however im not using any names. How would i go about inserting the information into my database? Thanks Dane Quote Link to comment https://forums.phpfreaks.com/topic/48477-solved-isset/ Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 use if (isset($_POST['name of element used'])) { or have a hidden textbox called "POSTED" and use if (isset($_POST['POSTED'])) { Quote Link to comment https://forums.phpfreaks.com/topic/48477-solved-isset/#findComment-237062 Share on other sites More sharing options...
Daney11 Posted April 24, 2007 Author Share Posted April 24, 2007 What do you mean by element? Thanks again Dane Quote Link to comment https://forums.phpfreaks.com/topic/48477-solved-isset/#findComment-237066 Share on other sites More sharing options...
Daney11 Posted April 24, 2007 Author Share Posted April 24, 2007 Ive tried using the javascript name ive used to submit the form but that aint working either. Any other ideas? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/48477-solved-isset/#findComment-237097 Share on other sites More sharing options...
wildteen88 Posted April 24, 2007 Share Posted April 24, 2007 If you don't name your form fields then the browser will use numbers as the names, for example $_POST[0] will be the first field, $_POST[1] will be the second, $_POST[2] will be the third etc. You should really name your fields, It will be a lot easier identifying where your data is coming from rather then numbers. Quote Link to comment https://forums.phpfreaks.com/topic/48477-solved-isset/#findComment-237126 Share on other sites More sharing options...
Daney11 Posted April 24, 2007 Author Share Posted April 24, 2007 Yeah, All my fields are named. And when i used a submit form at the end and submit my data it works perfect. However i dont want to use a button i want to use text "Send Mail" All my other forms are named. Quote Link to comment https://forums.phpfreaks.com/topic/48477-solved-isset/#findComment-237128 Share on other sites More sharing options...
wildteen88 Posted April 24, 2007 Share Posted April 24, 2007 You don't have to use a submit button if you don't want to. If you are using a link to submit the form then give the form itself a name and then use the following HTML to submit the form: <a href="javascript:void(0)" onClick="document.MYFORM.Submit();">Send Mail</a> When you click the link it will submit the form. In your code you don't check for the submit button, as you don't have one. All you do is check the required fields are filled in, such as To, Subject, From and Message for example. Quote Link to comment https://forums.phpfreaks.com/topic/48477-solved-isset/#findComment-237140 Share on other sites More sharing options...
Daney11 Posted April 24, 2007 Author Share Posted April 24, 2007 So how do i go about inserting the data into the database? My form submits. But because im using if (isset($_POST[''])) { I dont know where to go from there then.... Thanks Dane Quote Link to comment https://forums.phpfreaks.com/topic/48477-solved-isset/#findComment-237143 Share on other sites More sharing options...
wildteen88 Posted April 24, 2007 Share Posted April 24, 2007 You do somethink like this: $myVar = $_POST['myVar']; mysql_query("INSERT INTO table_here (col1) Values ('$myVar')"); Quote Link to comment https://forums.phpfreaks.com/topic/48477-solved-isset/#findComment-237155 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.