How to form strings in php [closed]
I have an table, Now i want when after filling this table
This is the table in ssl.php
page
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="TitleBar">Generate CSR</td>
</tr>
</table>
<table cellspacing="0" border="0" width="100%">
<tr>
<td>Country Name(only two letters) :</td>
<td >
<input name="countryname" type="text" id="countryname" MaxLength="2"/>
</td>
</tr>
<tr>
<td>State or Province Name :</td>
<td>
<input name="province" type="text" id="province"/>
</td>
</tr>
<tr>
<td>Locality Name :</td>
<td >
<input name="localityname" type="text" id="localityname"/>
</td>
<tr>
<td>Organization Name :</td>
<td>
<input name="organizationname" type="text" class="style16" id="organizationname"/>
</td>
</tr>
<tr>
<td>Organizational Unit Name :</td>
<td >
<input name="organizationunit" type="text" id="organizationunit"/>
</td>
</tr>
<tr>
<td>Common Name :</td>
<td>
<input name="commonname" type="text" id="commonname"/>
</td>
</tr>
<tr>
<td>Email Address :</td>
<td >
<input name="email" type="text" id="email"/>
</td>
</tr>
<tr>
<td style="padding-top:15px padding-bottom:10px" align="right">
<input name="gencsr" type="submit" id="button" value="Generate CSR" class="FormButton" />
</td>
</tr></table>
HERE is my inputs :-
Country Name(only two letters) :IN
State or Province Name :MAHARASHTRA
Locality Name :MUMBAI
Organization Name :Cofin Inc
Organizational Unit Name :Sales
Common Name :www.coufdffin.itdpl
I want my output like this :-
"/C=IN/ST=MAHARASHTRA/L=MUMBAI/O=Cofin Inc/OU=Sales/CN=www.coufdffin.itdpl"
How can i make the string in this format after post the table
UPdate
now i am using this
$dn = array("C" => "".trim($_POST['countryname']),
"ST" => "".trim($_POST['province']),
"L" => "".trim($_POST['localityname']),
"O" => "".trim($_POST['org开发者_如何学运维anizationname']),
"OU" => "".trim($_POST['organizationunit']),
"CN" => "".trim($_POST['commonname']),
"emailAddress" => "".trim($_POST['email']));
$comma_separated = implode(",", $dn);
echo $comma_separated;
What can i do plz help me?
Instead of :
$dn = array("C" => "".trim($_POST['countryname']),
"ST" => "".trim($_POST['province']),
"L" => "".trim($_POST['localityname']),
"O" => "".trim($_POST['organizationname']),
"OU" => "".trim($_POST['organizationunit']),
"CN" => "".trim($_POST['commonname']),
"emailAddress" => "".trim($_POST['email']));
$comma_separated = implode(",", $dn);
echo $comma_separated;
do:
$dn = array("C" => "".trim($_POST['countryname']),
"ST" => "".trim($_POST['province']),
"L" => "".trim($_POST['localityname']),
"O" => "".trim($_POST['organizationname']),
"OU" => "".trim($_POST['organizationunit']),
"CN" => "".trim($_POST['commonname']),
"emailAddress" => "".trim($_POST['email']));
$str = '';
foreach($dn as $key => $val){
$str .= "/$key=$val";
}
Make (C,ST,L,O,OU,CN) in one array, ang get the post array after the page posted,
construct the new string using implode() method.
If these fields in your html form named correctly. you can simple "add" all these string together. Let's say the name of Country Name field in form is countryname. The PHP can then read the input IN with $_POST["countryname"]
. So you can generate the first session of your output like this
$output = "/C=" . $_POST["countryname"]
Use . to connect different strings in PHP.
Hope this help. :)
精彩评论