sohailsaif Posted October 10, 2014 Share Posted October 10, 2014 (edited) Hello everyone I am totally new in php i need some help in coding, Suppose I have 100 check boxes and one Textbox, I want to send the combined value of check box and textbox to another page. Like if i check a check box then the value of that check box and text box will be submitted to another page. Please see the attached b screenshot so you can get the ideaThanks in Advance Edited October 10, 2014 by Ch0cu3r Removed URGENT from title Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/ Share on other sites More sharing options...
Ch0cu3r Posted October 10, 2014 Share Posted October 10, 2014 Like if i check a check box then the value of that check box and text box will be submitted to another page. Yes. That is how forms work. What has the picture got do with your question? Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493214 Share on other sites More sharing options...
sohailsaif Posted October 10, 2014 Author Share Posted October 10, 2014 Yes. That is how forms work. What has the picture got do with your question? the question is related to that picture Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493263 Share on other sites More sharing options...
Ch0cu3r Posted October 10, 2014 Share Posted October 10, 2014 It would be helpful if you could at least explain what it is you are trying to do. You have so far posted a vague question and posted a picture which does not explain anything. Having the word URGENT in your title does not get your question answered anytime sooner. All members here have given up their own free time to help out. NB: I have cleaned this thread up Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493267 Share on other sites More sharing options...
sohailsaif Posted October 10, 2014 Author Share Posted October 10, 2014 It would be helpful if you could at least explain what it is you are trying to do. You have so far posted a vague question and posted a picture which does not explain anything. Having the word URGENT in your title does not get your question answered anytime sooner. All members here have given up their own free time to help out. NB: I have cleaned this thread up suppose there are 5 checkbox named .com, .net, .org, .co, .in and one textbox, when a user enters "example" in the textbox and checks ".com" checkbox, i want to send the values of textbox which is "example: and the value of checkbox ".com" within a single string like "example.com" to another page when the user clicks on button. Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493282 Share on other sites More sharing options...
ginerjm Posted October 10, 2014 Share Posted October 10, 2014 So - you really want an introduction to simple and basic php syntax. May we suggest reading the first few chapters of the manual? You'll learn a lot - especially how to concatenate strings. Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493285 Share on other sites More sharing options...
cyberRobot Posted October 10, 2014 Share Posted October 10, 2014 In case it helps, the following tutorial shows the basics on working with forms: http://php.net/manual/en/tutorial.forms.php Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493287 Share on other sites More sharing options...
sohailsaif Posted October 10, 2014 Author Share Posted October 10, 2014 So - you really want an introduction to simple and basic php syntax. May we suggest reading the first few chapters of the manual? You'll learn a lot - especially how to concatenate strings. i know how to concatenate strings and how to send it to another page, but the main problem are the checkboxes, because the selection of checkboxes depends on user as the user user can select any check box, So how to send the value of that checkbox which is selected? Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493292 Share on other sites More sharing options...
ginerjm Posted October 10, 2014 Share Posted October 10, 2014 (edited) What do you want to do when they select two or more checkboxes. Make a string like "example.com.net.org"? Edited October 10, 2014 by ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493294 Share on other sites More sharing options...
davidannis Posted October 10, 2014 Share Posted October 10, 2014 (edited) <input type="text" name="domain"><br> <input type="checkbox" value=".com" name="tld[]">.com<br> <input type="checkbox" value=".net" name="tld[]">.net<br> <input type="checkbox" value=".org" name="tld[]">.org<br> foreach($_POST['tld'] as $value){ echo $_POST['domain'].$value."<br>\n"; } will give you what you are looking for, output to the screen I believe. Of course, you need the rest of the HTML and the php, only provided the relevant pieces here. Edited October 10, 2014 by davidannis Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493298 Share on other sites More sharing options...
sohailsaif Posted October 13, 2014 Author Share Posted October 13, 2014 <input type="text" name="domain"><br> <input type="checkbox" value=".com" name="tld[]">.com<br> <input type="checkbox" value=".net" name="tld[]">.net<br> <input type="checkbox" value=".org" name="tld[]">.org<br> foreach($_POST['tld'] as $value){ echo $_POST['domain'].$value."<br>\n"; } will give you what you are looking for, output to the screen I believe. Of course, you need the rest of the HTML and the php, only provided the relevant pieces here. can you help me to asign the output data into a variable i am using this code, but its not giving the actual output foreach($tc=$_POST['tld'] as $value){ echo $tb=$_POST['domain'].$value."<br>\n"; } $dn=$tc. ' ' .$tb; echo "$dn"; Output: Array example.biz i just want the actual string. Please help me Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493437 Share on other sites More sharing options...
cyberRobot Posted October 13, 2014 Share Posted October 13, 2014 Output: Array example.biz i just want the actual string. "Array" is coming from this line: foreach($tc=$_POST['tld'] as $value){ Since $_POST['tld'] is an array of checkbox values, $tc becomes "Array". To get the string, you just need to take the suggestion by davidannis and assign it to a variable. For example: $selections = array(); foreach($_POST['tld'] as $value){ $selections[] = $_POST['domain'].$value; } echo implode('<br>', $selections); Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493448 Share on other sites More sharing options...
sohailsaif Posted October 15, 2014 Author Share Posted October 15, 2014 "Array" is coming from this line: foreach($tc=$_POST['tld'] as $value){ Since $_POST['tld'] is an array of checkbox values, $tc becomes "Array". To get the string, you just need to take the suggestion by davidannis and assign it to a variable. For example: $selections = array(); foreach($_POST['tld'] as $value){ $selections[] = $_POST['domain'].$value; } echo implode('<br>', $selections); thank you so much for your help Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493569 Share on other sites More sharing options...
sohailsaif Posted October 15, 2014 Author Share Posted October 15, 2014 (edited) <?php$dt=date("Y-m-d");$tm=date("h:i:s");$dtm= $dt." ". $tm;$str="Merc200";$pwd=md5("$str");$src=("WEBCC-TUBANAEENG");$ochecksum= md5("$src"+"$dtm"+"$pwd");echo "$ochecksum";$term=$_POST['term'];$ns1=$_POST['ns1'];$ns2=$_POST['ns2']$reg_contact_type=$_POST['ctType1'];$reg_company=$_POST['reg_company'];$reg_fname=$_POST['reg_fname'];$reg_lname=$_POST['reg_lname'];$reg_addr1=$_POST['reg_addr1'];$reg_addr2=$_POST['reg_addr2'];$reg_state=$_POST['reg_state'];$reg_city=$_POST['reg_city'];$reg_postcode=$_POST['reg_postcode'];$reg_telephone=$_POST['reg_telephone'];$reg_fax=$_POST['reg_fax'];$reg_country=$_POST['reg_country'];$reg_email=$_POST['reg_email'];$custom_reg1=$_POST['custom_reg1'];$custom_reg2=$_POST['custom_reg2'];$custom_reg3=$_POST['custom_reg3'];$adm_contact_type=$_POST['ctType2'];$admcompany=$_POST['adm_company'];$admfname=$_POST['adm_fname'];$admlname=$_POST['adm_lname'];$admaddr1=$_POST['adm_addr1'];$adm_addr2=$_POST['adm_addr2'];$adm_state=$_POST['adm_state'];$adm_city=$_POST['adm_city'];$adm_postcode=$_POST['adm_postcode'];$adm_telephone=$_POST['adm_telephone'];$adm_fax=$_POST['adm_fax'];$adm_country=$_POST['adm_country'];$adm_email=$_POST['adm_email'];$custom_adm1=$_POST['custom_adm1'];$custom_adm2=$_POST['custom_adm2'];$custom_adm3=$_POST['custom_adm3'];$tec_contact_type=$_POST['ctType3'];$tec_company=$_POST['tec_company'];$tec_fname=$_POST['tec_fname'];$tec_lname=$_POST['tec_lname'];$tec_addr1=$_POST['tec_addr1'];$tec_addr2=$_POST['tec_addr2'];$tec_state=$_POST['tec_state'];$tec_city=$_POST['tec_city'];$tec_postcode=$_POST['tec_postcode'];$tec_telephone=$_POST['tec_telephone'];$tec_fax=$_POST['tec_fax'];$tec_country=$_POST['tec_country'];$tec_email=$_POST['tec_email'];$custom_tec1=$_POST['custom_tec1'];$custom_tec2=$_POST['custom_tec2'];$custom_tec3=$_POST['custom_tec3'];$bil_contact_type=$_POST['ctType4'];$bil_company=$_POST['bil_company'];$bil_fname=$_POST['bil_fname'];$bil_lname=$_POST['bil_lname'];$bil_addr1=$_POST['bil_addr1'];$bil_addr2=$_POST['bil_addr2'];$bil_state=$_POST['bil_state'];$bil_city=$_POST['bil_city'];$bil_postcode=$_POST['bil_postcode'];$bil_telephone=$_POST['bil_telephone'];$bil_fax=$_POST['bil_fax'];$bil_country=$_POST['bil_country'];$bil_email=$_POST['bil_email'];$custom_bil1=$_POST['custom_bil1'];$custom_bil2=$_POST['custom_bil2'];$custom_bil3=$_POST['custom_bil3'];$username=$_POST['username'];$password=$_POST['password'];$strContent="&source=$src";$strContent="&otime=$dtm";$strContent.="&url=http://www.oziq.net";$strContent="&ochecksum=$ochecksum";$strContent.="&domainname=sohailsaif.com";$strContent="&ns1=$ns1";$strContent="&ns2=$ns2";$strContent="®_contact_type=ctType1";$strContent="®_company=$reg_company";$strContent="®_fname=$reg_fname";$strContent="®_lname=$reg_lname";$strContent="®_addr1=$reg_addr1";$strContent="®_addr2=$reg_addr2";$strContent="®_state=$reg_state";$strContent="®_city=$reg_city";$strContent="®_postcode=$reg_postcode";$strContent="®_telephone=$reg_telephone";$strContent="®_fax=$reg_fax";$strContent="®_country=$reg_country";$strContent="®_email=$reg_email";$strContent="&custom_reg1=$custom_reg1";$strContent="&custom_reg2=$custom_reg2";$strContent="&custom_reg3=$custom_reg3";$strContent="&adm_contact_type=$ctType2";$strContent="&adm_company=$adm_company";$strContent="&adm_fname=$adm_fname";$strContent="&adm_lname=$adm_lname";$strContent="&adm_addr1=$adm_addr1";$strContent="&adm_addr2=$adm_addr2";$strContent="&adm_state=$adm_state";$strContent="&adm_city=$adm_city";$strContent="&adm_postcode=$adm_postcode";$strContent="&adm_telephone=$adm_telephone";$strContent="&adm_fax=$adm_fax";$strContent="&adm_country=$adm_country";$strContent="&adm_email=$adm_email";$strContent="&custom_adm1=$custom_adm1";$strContent="&custom_adm2=$custom_adm2";$strContent="&custom_adm3=$custom_adm3";$strContent="&tec_contact_type=$ctType3";$strContent="&tec_company=$tec_company";$strContent="&tec_fname=$tec_fname";$strContent="&tec_lname=$tec_lname";$strContent="&tec_addr1=$tec_addr1";$strContent="&tec_addr2=$tec_addr2";$strContent="&tec_state=$tec_state";$strContent="&tec_city=$tec_city";$strContent="&tec_postcode=$tec_postcode";$strContent="&tec_telephone=$tec_telephone";$strContent="&tec_fax=$tec_fax";$strContent="&tec_country=$tec_country";$strContent="&tec_email=$tec_email";$strContent="&custom_tec1=$custom_tec1";$strContent="&custom_tec2=$custom_tec2";$strContent="&custom_tec3=$custom_tec3";$strContent="&bil_contact_type=$ctType4";$strContent="&bil_company=$bil_company";$strContent="&bil_fname=$bil_fname";$strContent="&bil_lname=$bil_lname";$strContent="&bil_addr1=$bil_addr1";$strContent="&bil_addr2=$bil_addr2";$strContent="&bil_state=$bil_state";$strContent="&bil_city=$bil_city";$strContent="&bil_postcode=$bil_postcode";$strContent="&bil_telephone=$bil_telephone";$strContent="&bil_fax=$bil_fax";$strContent="&bil_country=$bil_country";$strContent="&bil_email=$bil_email";$strContent="&custom_bil1=$custom_bil1";$strContent="&custom_bil2=$custom_bil2";$strContent="&custom_bil3=$custom_bil3";$strContent="&username=$username";$strContent="&password=$password";$postfield=$strContent;$ch=curl_init();$url2="https://ote.webnic.cc/jsp/pn_newreg.jsp";curl_setopt($ch, CURLOPT_URL, $url2);curl_setopt($ch,CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, $postfield);$strReturn=curl_exec($ch);echo $strReturn;curl_close($ch);?> I am getting an error Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\Dashboard\register.php on line 13 can anyone please help me to solve the error? Edited October 15, 2014 by sohailsaif Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493570 Share on other sites More sharing options...
Barand Posted October 15, 2014 Share Posted October 15, 2014 "unexpected T_xxxxxxxxxx" error means if expected to find something else before it encountered "xxxxxxxxxxx". Check the end of the previous line to see if anything is missing. Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493572 Share on other sites More sharing options...
codefossa Posted October 15, 2014 Share Posted October 15, 2014 Line 12 needs a semicolon. Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493574 Share on other sites More sharing options...
Barand Posted October 15, 2014 Share Posted October 15, 2014 Line 12 needs a semicolon. Well done, Sherlock! Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493578 Share on other sites More sharing options...
codefossa Posted October 15, 2014 Share Posted October 15, 2014 Well done, Sherlock! It seems my identity has been revealed. I don't see the problem with showing them what it is here so they can get used to looking for things before the line shown. Quote Link to comment https://forums.phpfreaks.com/topic/291550-guys-i-need-help-some-need-to-combine-checkbox-and-textbox-value/#findComment-1493579 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.