jeudi 9 avril 2015

PHP inserting values into the link

I have input that will generate inputs (user´s choice how many): if he choices to write to the input for the example number 2 .. it will generate Two inputs for URL two inputs for title and two inputs for color inputs and two checkboxes(if isset it will put into the <a> _blank.


I have problem into putting all these informations into the <a>.


This is my code:



if(isset($_POST['vice'])){
?>
<div class="howmany">
<form method="post" action="">
<label class="howmanyURL">Zde vepište kolik chcete zadat URL</label><input id="howmanyURLinput" type="text" name="generator"/>
<input type="submit" id="vicesubmit" name="generatingsubmit"/>
</form>
</div>
<?php
}
if (isset($_POST['generator']) AND isset($_POST['generatingsubmit'])) {
$generator = $_POST['generator'];
$cislo = 0;
echo "<div class='centerfor'>";
echo "<div class='contentfor'>";
echo "<form method='post' action=''>";
for($i = 0; $i < $generator; $i++){
$cislo++;
echo "<label>URL" . $cislo .":</label><input class='forinputy' type='text' name='jmeno[]'/><br>";
echo "<label>Titulek" . $cislo.":</label><input class='forinputyt' type='text' name='jmenot[]'/><br>";
echo "<label>Barva" . $cislo.":</label><input class='forinputyc' type='color' name='jmenoc[]'/><br>";
echo "<label>Chci zoobrazit v dalším okně" . $cislo.":</label><input class='forinputych' type='checkbox' name='jmenoch[]'/><br>";
}
echo "<input type='submit' id='submitfor' name='submitfor' />";
echo "</form>";
echo "</div>";
echo "</div>";
}
if(isset($_POST['submitfor'])) {
$jmeno= $_POST['jmeno'];
$titulek= $_POST['jmenot'];
$barva= $_POST['jmenoc'];

foreach($jmeno as $j ){
$parse = str_ireplace('www.', '', parse_url($j));
$ahref = "<a href='" . $j . "'";
}
foreach($titulek as $t){
$ahref .= "title ='" . $t . "'";
}
foreach($barva as $c){
setcookie("barva", $c);
}
foreach($jmeno as $n){
$ahref .= "target= '_blank' style=' color:" . $_COOKIE['barva'] . "; text-decoration: none ;'>" . $parse['host'] . "</a><br>";
echo $ahref;
}
}

Aucun commentaire:

Enregistrer un commentaire