im try to take data from html form and transfer it to my DB using post and php. Whenever I do, the data changes to something unfamiliar to me.  I'm very new to programming, please help me.  my html code:  &lt;form action="insert.php" method="post"&gt;                         &lt;tbody&gt;                             &lt;tr&gt;                                 &lt;td width="20%"&gt;privet name&lt;/td&gt;                                 &lt;td&gt;&lt;input type="text" id="privetname" name="fname" size="16"&gt;&lt;/td&gt;                             &lt;/tr&gt;                              &lt;tr&gt;                                 &lt;td width="20%"&gt;&amp;nbsp;last name&lt;/td&gt;                                 &lt;td&gt;&lt;input type="text" id="lastname" name="lname" size="16"&gt;&lt;/td&gt;                             &lt;/tr&gt;                              &lt;tr&gt;                                 &lt;td width="20%"&gt;&amp;nbsp;phone&lt;/td&gt;                                 &lt;td&gt;&lt;input type="text" id="phone" name="phone" size="16"&gt;&lt;/td&gt;                             &lt;/tr&gt;                              &lt;tr&gt;                                 &lt;td width="20%"&gt;&amp;nbsp;email&lt;/td&gt;                                 &lt;td&gt;&lt;input type="email" id="email" name="email" size="16"&gt;&lt;/td&gt;                             &lt;/tr&gt;                              &lt;tr&gt;                                 &lt;td width="20%"&gt;&amp;nbsp;birthday&lt;/td&gt;                                 &lt;td&gt;&lt;input type="date" id="birthday" name="birthday"&gt;&lt;/td&gt;                             &lt;/tr&gt;                              &lt;tr&gt;                                 &lt;td width="20%"&gt;&amp;nbsp;anniversary&lt;/td&gt;                                 &lt;td&gt;&lt;input type="date" id="anniversary" name="anniversary"&gt;&lt;/td&gt;                             &lt;/tr&gt;                              &lt;tr&gt;                                 &lt;td&gt;&lt;button type="submit"&gt;&lt;font size="+1"&gt;Create Customer&lt;/font&gt;&lt;/button&gt;&lt;/td&gt;                             &lt;/tr&gt;                         &lt;/tbody&gt;                     &lt;/form&gt;   my php code:  $sql="INSERT INTO customer (fname, lname, phone, email, birthday, anniversary)   VALUES   ('$_POST[fname]','$_POST[lname]','$_POST[phone]','$_POST[email]','$_POST[birthday]','$_POST[anniversary]')"; /* ,'$_POST[birthday]','$_POST[anniversary]' */
326
I'm setting up a new server and want to support UTF-8 fully in my web application. I have tried this in the past on existing servers and always seem to end up having to fall back to ISO-8859-1.  Where exactly do I need to set the encoding/charsets? I'm aware that I need to configure Apache, MySQL, and PHP to do this — is there some standard checklist I can follow, or perhaps troubleshoot where the mismatches occur?  This is for a new Linux server, running MySQL 5, PHP, 5 and Apache 2.
92236
I have an xml file which I would like to create a form/table around to add, edit and delete records using PHP.  Currently I use simpleXML to load the XML file, and display its content on various pages.  Is there any way I can create a table that shows all results, and allows me to either edit or delete that particular row of the table which represents a full record within the XML file.    When clicking edit I would like the details from the record to appear in a form which the user can change and then save out, updating the XML file and the corresponding web page.  I need this done in PHP, preferably using SimpleXML, though open to suggestions of other ways to do this with PHP.  Cheers
121190
I'm trying to use ajax to update two different parts of a drupal form from just one form input blur.  I have the standard ajax stuff on my input:  $my_form['my_input']['#ajax'] = array(   'callback' =&gt; 'my_callback',   'wrapper' =&gt; 'my_target_div',   'event' =&gt; 'blur', );   This is working well, swapping out my div when the input is updated ... however I also want to update another form input elsewhere in the form with different code as a result of the blur on my original input.  Is this possible, any ideas?  Edit: For clarity, here's my real world example:   Content type 'movie' Added field 'primary_title' When 'primary_title' is updated my ajax callback checks for similar strings and returns html. The html from the callback is inserted into an empty div.  That part is working great!   I'm trying to also modify the standard node 'title' input, giving it the value of 'primary_title' after I have done some regex to tidy up the string (removing "The" or "A" from the start etc) The result will be two title fields, one with the complete title 'primary_title' and one trimmed 'title' that will be useful for sorting and displaying records.
18539
I've got a php script. Most of the time the script returns html, which is working fine, but on one occasion (parameter ?Format=XML) the script returns XML instead of HTML.  Is there any way to change the returned mime type of the php output on the fly from text/html to text/xml or application/xml?
105831
Drupal 7. Custom module. I have a content type 'RFI' with a handful of fields I created with Drupal UI. I want a user to: fill out a form &amp; click submit while drupal: saves fields to database, creates a new node of 'RFI' and populates the fields of the node with the content provided by the form's corresponding fields.  From what I understand:  Build a form with fields (taking from the 'DBTNG examples' module just for clarity):  function rfi_build_form($form, &amp;$form_state) { $form = array();  $form['add'] = array( '#type'  =&gt; 'fieldset', '#title' =&gt; t('Add a person entry'), ); $form['add']['name'] = array( '#type'  =&gt; 'textfield', '#title' =&gt; t('Name'), '#size'  =&gt; 15, ); $form['add']['surname'] = array( '#type'  =&gt; 'textfield', '#title' =&gt; t('Surname'), '#size'  =&gt; 15, ); $form['add']['age'] = array( '#type'  =&gt; 'textfield', '#title' =&gt; t('Age'), '#size'  =&gt; 5, '#description' =&gt; t("Values greater than 127 will cause an exception. Try it - it's a    great example why exception handling is needed with DTBNG."), ); $form['add']['submit'] = array( '#type'  =&gt; 'submit', '#value' =&gt; t('Add'), ); return $form; }   Here the form fields are saved to database with database API.  function rfi_build_submit($form, &amp;$form_state) { global $user;  // Save the submitted entry. $entry = array( 'name'    =&gt; $form_state['values']['name'], 'surname' =&gt; $form_state['values']['surname'], 'age'     =&gt; $form_state['values']['age'], 'uid'     =&gt; $user-&gt;uid, ); $return = dbtng_example_entry_insert($entry); if ($return) { drupal_set_message(t("Created entry @entry", array('@entry' =&gt; print_r($entry, TRUE)))); } }   Now here is how I know how to create a node of RFI type. How do I take the values of the fields above [name], [surname], [age] and have them related to corresponding fields in my content type?  function rfi_build_type($form, &amp;$form_state){ $node = new stdClass(); $node-&gt;type = 'rfi'; $node-&gt;name = ''; $node-&gt;surname = ''; $node-&gt;age = ''; $node-&gt;language = 'en'; $node-&gt;uid = 1; node_save($node); }   I was thinking that since the fields have been saved already, that I could use a database query to get these values, but intuition tells me I'm overlooking something.  Thank you!
118937
I have a webform on my site and on user submission, I want to send the webform data to some php application that get the value of some variables from the URL.   This task requires me to access the webform submitted data when the user clicks "Submit" button and construct a URL (/myphpapplication?query=....) containing user filled webform values.  Please help me to achieve this.
32884
If I define an array in PHP such as (I don't define its size):  $cart = array();   Do I simply add elements to it using the following?  $cart[] = 13; $cart[] = "foo"; $cart[] = obj;   Don't arrays in PHP have an add method, for example, cart.add(13)?
94609
I'm working at an app which would make a POST ajax request to a PHP script on my server. The script would query the database and return a row of records, as an array. (One array for each row, containing elements such as id, title, etc). I then want to use json_encode() to encode this array, and pass it back to the javascript which will use it to display the records.  1) How can I return the JSON encoded string to the javascript? 2) How will the javascript loop through the rows and access their fields?
40506
I am writing a function that adds an ID number to an array and puts the array in the usermeta. $_GET['auction'] is the post_id.  Below is the function:  $reminders = get_user_meta( $current_user-&gt;ID, "reminders" ); print_r( $reminders ); if( in_array( $_GET['auction'], $reminders ) ) {     echo "Failed: Auction already in list"; } else {     array_push( $reminders, intval( $_GET['auction'] ) );     if ( update_user_meta( $current_user-&gt;ID, "reminders", $reminders ) ) {         echo "Success";     } else {         echo "Failed: Could not update user meta";     } } print_r( $reminders );   Here is the output after adding one auction:  Array ( )  Success Array ( [0] =&gt; 7 )    Here is the output after adding two auctions:  Array ( [0] =&gt; Array ( [0] =&gt; 7 ) )  Success Array ( [0] =&gt; Array ( [0] =&gt; 7 ) [1] =&gt; 73 )   And here is the output after adding three auctions:  Array ( [0] =&gt; Array ( [0] =&gt; Array ( [0] =&gt; 7 ) [1] =&gt; 73 ) )  Success Array ( [0] =&gt; Array ( [0] =&gt; Array ( [0] =&gt; 7 ) [1] =&gt; 73 ) [1] =&gt; 0 )   Notice that adding a new element to the array using array_push works fine. But when the array is stored in the usermeta then retrieved again, the last element in the array has been put into an array of its own, creating an infinitely dimensional array. I'd prefer to keep this array one dimensional.  Is there a way I can run update_user_meta and get_user_meta without it changing the structure of my array?
61070
Today I got requirement to get the list data using rest and bind to html drop down . I am getting the information by filtering it from browser  (_api/web/lists/GetByTitle('Tabletop%20Sessions')/items?Select=Title";)   . As this is my first program can any one help me what's wrong in my below code in binding the data to drop-down.  &lt;style type="text/css"&gt;  .textbox{      font-family : inherit;      font-size   : 100%;width: 275px;      border: 4px solid #F7F9FA;      -webkit-border-radius: 3px;      -moz-border-radius: 3px;      border-radius: 3px;      -moz-box-shadow: 2px 3px 3px rgba(0, 0, 0, 0.06) inset, 0 0 1px #95a2a7 inset;      -webkit-box-shadow: 2px 3px 3px rgba(0, 0, 0, 0.06) inset, 0 0 1px #95A2A7 inset;      box-shadow: 2px 3px 3px rgba(0, 0, 0, 0.06) inset, 0 0 1px #95A2A7 inset;      height: 30px;      width: 275px;      display: block;  } .fontsize{     font-style: arial;font-size:17px; } .select{     width: 285px;height: 25px; } &lt;/style&gt;  &lt;script src="//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js" type="text/javascript"&gt; &lt;/script&gt; &lt;script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"&gt; &lt;/script&gt; &lt;script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js "&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.js"&gt;&lt;/script&gt;  &lt;script src="https://code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;  &lt;link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"&gt;  &lt;script src="//code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;  &lt;script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"&gt;&lt;/script&gt;  &lt;link rel="stylesheet" href="/resources/demos/style.css"&gt;  &lt;body&gt; &lt;table&gt; &lt;tr&gt;    &lt;td colspan="2"&gt;&lt;img align="right" src=" Image URL"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;    &lt;td colspan="2"&gt;&lt;img src=""/&gt; &lt;/td&gt; &lt;/tr&gt;  &lt;/tr&gt; &lt;tr&gt;  &lt;td class="fontsize"&gt;Months:&lt;/td&gt;  &lt;td&gt;        &lt;select id="drbfunction" class="select"&gt;        &lt;option selected="selected"&gt;Select&lt;/option&gt;        &lt;/select&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td class="fontsize"&gt;&lt;br&gt;Programes:&lt;/td&gt;  &lt;td&gt;&lt;br&gt;        &lt;select id="drbprogrames" class="select"&gt;        &lt;option selected="selected"&gt;Select&lt;/option&gt;  &lt;/tr&gt; &lt;/table&gt; &lt;script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js "&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.js"&gt;&lt;/script&gt; &lt;script&gt; SP.SOD.executeFunc('sp.js', 'SP.ClientContext', getprogrames); function getprogrames(sender, args) {     alert("in Programes");     var userid = _spPageContextInfo.userId;     var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Tabletop%20Sessions')/items?Select=Title";     var requestHeaders = { "accept": "application/json;odata=verbose" };     $.ajax({         url: requestUri,         contentType: "application/json;odata=verbose",         headers: requestHeaders,         success: onprogramQuerySucceeded (data) {          var listData = data.d.results;          var itemCount = listData.length;          var processedCount = 0;          var functions = document.getElementById("drbprogrames");          for (var i = 0; i &lt; result.length; i++)            {                var option = document.createElement('option');                option.text = option.value = result[i].Title;                functions.add(option);            }       },         error: function (data) {            alert(failure(data));        }     }); }  &lt;/script&gt;
34148
I created a landing page which auto-populates first name, last name and the email. Now I need to pass these 3 along with what radio buttons are selected by the user to a data extension other than the sent one.   I guess is something to do with the submit button for the radio buttons form but how? I have to tell somehow which data extension and what fields/values to add but I don't know how.  Is there any easy way to do that?  Thanks, VD
80089
I have seen a solution that I don't get to work - I need to change data type from string to integer and I did what is shown i the image below Can someone point out what I do wrong?
96246
I have been looking for a solution to this, have seen some sort of add on called dynamic text but I don't think that suits my needs.  Basically, I have a multi dimensional array. Basically what I want to do is pass a value from the array into the 'to' field in Contact Form 7. I know I could just write my own contact form but I'm using the plugin quite extensively on the site so for integration it would be nice to use it for this new thing I'm building too. Any clues, doesn't seem you can put php straight in to the to field, as this didn't work to well!:  &lt;?php echo $passmein;?&gt;
99555
I am trying to pass the email value from a data extension to HTML. I am using the CloudPagesURL() in my email in attempt to grab the subscriber's email.  Here is my code syntax that I am attempting to use:  Email Code:  &lt;p&gt;&lt;a title="MyPage" href="%%=RedirectTo(CloudPagesURL(505,'Email Address',@EmailAddress))=%%" alias="ThisAlias" conversion="false"&gt;Click to unsubscribe page 505&lt;/a&gt;&lt;/p&gt;   CloudPage AMPScript Code:  %%[  VAR @emailAddress  SET @emailAddress = RequestParameter("emailaddr")  ]%%   Cloudpage HTML Code:  &lt;td width='155' valign='bottom'&gt;&lt;input type='text' name='Name1' value='%%=v(@emailAddress)=%%' id='Name1' /&gt;&lt;/td&gt;   Any reason as to why this doesn't work? My syntax might just be wrong or I might be using the CloudPagesURL() function incorrectly.
67969
I have a custom search form that I posts a year + month, such as 2014-04 I would like to get all nodes created that month, when I create the timestmap I use: "SELECT .......         AND changed >= 'strtotime($date)'"  This is the code for form date:  $form['aqar_date'] = array( '#type' =&gt; 'date_select',  '#title' =&gt; t('Date'), '#prefix' =&gt; '&lt;div id="space_replace" class="search-title-date"&gt;   &lt;h2&gt;Node date&lt;/h2&gt;', '#suffix' =&gt; '&lt;/div&gt;',      '#date_format' =&gt; 'Y-m', '#default_value' =&gt; date('Y-m'), '#date_year_range' =&gt; '-4:+0',  );   This is the form submit:  $start_date = strtotime($date); $query = " SELECT `nid` FROM `node` WHERE  `type` = 'custom'  AND `changed` &gt;= '$start_date'";   But I'm not getting, I need a way to specify to only this month period not this month and newer!  Thanks!
22775
Is there a library or acceptable method for sanitizing the input to an html page?  In this case I have a form with just a name, phone number, and email address.    Code must be C#.  For example:  "&lt;script src='bobs.js'&gt;John Doe&lt;/script&gt;" should become "John Doe"
101805
I am not familiar with PHP at all and had a quick question.  I have 2 variables pricePerUnit and InvoicedUnits. Here's the code that is setting these to values:  $InvoicedUnits = ((string) $InvoiceLineItem-&gt;InvoicedUnits); $pricePerUnit = ((string) $InvoiceLineItem-&gt;PricePerUnit);   If I output this, I get the correct values. Lets say 5000 invoiced units and 1.00 for price.  Now, I need to show the total amount spent. When I multiply these two together it doesn't work (as expected, these are strings).  But I have no clue how to parse/cast/convert variables in PHP.  What should I do?