Im trying to make a html form processed in php that outputs to pdf and is print ready.
This is what I have:
A page requesting the categories to include
A page which presents text areas for that categories
A page which displays the final result with an option to print and or make a pdf.
I can make all the information pass along the pages what im lacking is way to display the content properly formatted.
I need this layout:
Text here bold: Description of item
Description of item
(precisely one empty line)
Some more bold text: Description of item
Description of item
and so on.
Im a bit stumbled since the Item descriptions are coming from text areas of which I am able to preserve the line breaks by echoing <.pre> (please excuse the dot, i dont understand how to escape the tag ;) tags along, which end up including all the white space due to the textarea cols.
Assuming I have two textareas and two variables with the titles posting to the last page, how would i go about formatting it properly?
Thank you.
-----EDIT-------
To clarify what I intend:
I have 3 pages:
1 one:
<div class="menu">
Por favor seleccione os conteúdos:
<form name="Categorias" action="Elementos_Descritivos.php" method="post">
<div class="cb-row">
<label for="nome">Nome:</label>
<input id="nome" name="Nome" type="checkbox" value="Nome" checked />
</div>
<div class="cb-row">
<label for="data">Data:</label>
<input id="data" name="Data" type="checkbox" value="Data" checked />
</div>
<div class="cb-row">
<label for="cliente">Cliente:</label>
<input id="cliente" name="Cliente" type="checkbox" value="Cliente" checked />
</div>
<div class="cb-row">
<label for="ob">Observações:</label>
<input id="ob" name="Observacoes" type="checkbox" value="Observacoes" checked />
</div>
<div class="submit">
<input type="submit" value="Seguinte" />
</div>
</form>
</div>
</div>
In this one you choose wich categories go into the doc.
Page 2:
<body>
<?php
$Nome = $_POST["Nome"];
$Data = $_POST["Data"];
$Cliente = $_POST["Cliente"];
$Observacoes = $_POST["Observacoes"];
$Nome1 = "Nome";
$Data1 = "Data";
$Cliente1 = "Cliente";
$Observacoes1 = "Observacoes";
echo "<div class=\"menu2\">
<form name=\"Detalhes\" action=\"Pre_Impressao.php\" method=\"post\">
Por favor preencha os todos os campos em branco:<br/><br/>";
#######################################_NOME_######################################
if ( $Nome == $Nome1 ) {
echo "<div> Nome: <textarea name=\"Nome\" rows=\"6\" cols=\"60\"></textarea></div> <br/>";
}
########################################_DATA_#####################################
if ( $Data == $Data1 ) {
echo "<div> Data: <textarea name=\"Data\" rows=\"6\" cols=\"60\"></textarea></div><br/>";
}
########################################_CLIENTE_##################################
if ( $Cliente == $Cliente1 ) {
echo "<div> Cliente: <textarea name=\"Cliente\" rows=\"6\" cols=\"60\"></textarea></div> <br/>";
}
#######################################_OBSERVACOES_###############################
if ( $Observacoes == $Observacoes1 ) {
echo "<div> Observacoes: <textarea name=\"Observacoes\" rows=\"6\" cols=\"60\"></textarea></div><br/>";
}
####################################################################################
echo "<div class=\"submit\">
<input type=\"submit\" value=\"Seguinte\" />
</div>
</form>
</div>
?>
The second page displays text areas for filling information about hte categories selected in the previous page.
And then page 3, which ought to display the inputs nicely formatted, that's were im stumbled, I know my php is hideous, and i would be better off with a for each loop but for now im trying to focus on getting it done rather than getting it done in a better way :)
If im still not being clear in any aspect please let me clarify so i can improve the post.
Thanks.
You can put PHP code inside normal HTML code (or PDF code), but it might be easier to iterate and generate this way:
If I remember correctly, you can put your data in a table and the formatting will render properly in a PDF. I have also come across the issue that some CSS properties do not render properly in PDF. Hope that helps.
Related
I want to create a webpage that posts onto itself text inserted into an input field, using CSS to stylize said text once it becomes part of the page. However, I don't know how to refer to it with a CSS selector. I've done what every HTML-newb tries when encountering a problem and wrapped both the form code and PHP statement in classified DIVs, however, the computer visibly doesn't know what I'm trying to address. Likewise, wrapping the PHP statement in paragraph tags doesn't apply to it the stylization said tags are associated with.
For Reference, Form & PHP Code:
<form method = "post">
<textarea name="input"></textarea>
<input type="submit">
</form>
<?php echo $_POST['input'];?>
My apologies if the solution to this is obvious; I can't find information addressing it.
you could inline style it or with a class.
<form method = "post">
<textarea name="input"></textarea>
<input type="submit" name="submit">
</form>
<div class="input-value">
<?php
if(isset($_POST['submit])) {
echo $_POST['input'];
}
?>
</div>
use .input-value class in css
Please try this!
<form method = "post">
<textarea name="input"></textarea>
<input type="submit">
</form>
<?php echo "<div style='color:red;font-family:verdana;font-size:300%'>" .
$_POST['input'] . "</div>" ?>
Are you looking for this? Please let me know! Thanks!
I have large html code inside my DATABASE. I need to get that into textarea for editing purpose. I can do that all but i have problem when it is displaying code into textarea. Half code is inside of textarea but other half display form not code and it display it out of textarea. (See Picture ).
Passing data from DATABASE:
<?php
include_once("scripts/connect.php");
$id = $_GET['id'];
$result = mysqli_query($mysqli, "SELECT * FROM formsAndCategories WHERE id=$id");
while($res = mysqli_fetch_array($result))
{
$category = $res['category'];
$form = $res['form'];
}?>
Displaying code from DATABASE (issue is with textarea. its displaying wrong on page):
<form name="form1" method="post" action="edit.php">
<label class="fb-textarea-label">Form Code</label><textarea name="form" class="form-control" rows="25"><?php echo $form;?></textarea>
<label class="fb-text-label">Category</label> <td><input type="text" name="category" class="form-control" value="<?php echo $category;?>"></td>
<input type="hidden" name="id" value="<?php echo $_GET['id'];?>"></td>
<input type="submit" class="btn btn-success" name="update" value="Update"></td>
</form>
So far i tryed to do that on plain page. I was thinking maby those all (bootstraps, jquery and css etc) are ruining it all. But nothing.
Then i found out that there is no character limit in textarea but anyway i tryed to set character limit with maxlength="200000".
Then i tryed different code because i was thinking maby there is problem with html form code but nothing.
If it is not possible in this way then maby there is different way to do this ?
If somebody can help me out with this it would be great.
Thank You.
Following code will escape HTML characters. In the code above, HTML characters are not escaped and directly appending HTML to text box is causing the HTML breakup.
May be following solution will work.
<textarea name="form" class="form-control" rows="25"><?php echo htmlentities($form);?></textarea>
or
<textarea name="form" class="form-control" rows="25"><?php echo htmlspecialchars($form);?></textarea>
I know this is a weird question and maybe there are better solutions but in this step of my project it difficult to reform project.
I have some pairs of tags in my html similar to this:
<div>
<label for="first">text</label>
<input id="first" />
</div>
<div>
<label for="second">text</label>
<someTag></someTag>
<input id="second" />
</div>
I intend to generate this html with php, some thing like this code:
<?php
$form = new htmlform('formname');
echo $form->label('text');
echo $form->input('first');
echo $form->label('text');
echo $form->input('first');
?>
here is the problem...
as you see I type input id in second line but labels need that id too.
how can I put text in second line and use that in first line?
any byref or some thing.?.
Can you consider some
labeled_input(id, text)
that generates both, the label and the input?
I've a column inside my table to put Html codes, I will use this table for email templating.
I have inside my page, all the templates inside my table, with two buttons, one to remove, and another one to edit.
The edit button shows the code inside a textbox, and to do the preview I did an echo to the code column.
<div class="tempcolumn">
<div><textarea name="ai" rows="15" cols="100" name="code" placeholder="Code">
<?php echo $get_temp; ?></textarea></div>
</div>
Preview
<div class="tempcolumn">
<p><?php echo $get_temp; ?></p>
<div></div>
</div>
To recognize the code and the id i created an hidden input
<input type="hidden" name="temp_id" value="'.$val['template_id'].'">
<input type="hidden" name="temp_code" value="'.$val['text'].'">
The script is working, but when i insert inside the code column some "<" or "=" doesn't work
Is inferfering because it reads the input value like this:
<input type="hidden" name="temp_id" value=" Value here + 'random character that closes the tag' ">
Is there a easier way to do that?
Thanks
You can try;
htmlspecialchars($value)
This will convert html characters to their non-interfering cousins.
See http://docs.php.net/manual/en/function.htmlspecialchars.php as I can't post the equivalents without them becoming characters.
Hey Fellow Programmers,
I have a slight problem and I cant find the right answer online.
Basically what I need to do is, a user inserts content into a text box and then selects a check box. Whichever check box is selected is what table the text box content is supposed to insert into. **Both check boxes can be selected so the user can upload to two diff tables, before you ask no I cannot just upload to a diff row it has to be a completely diff table.
Let me know if I am not clear, and thanks in advance
HTML CODE:
<body class="login">
<div class="wrapper">
<h1><img src="img/logo-big.png" alt="" class='retina-ready' width="59" height="49">FLAT</h1>
<div class="login-body">
<form action="db_pre_panel.php" name="login" class='form-validate' id="test" method="post">
<div class="control-group">
<div class="email controls">
<h3>TEST</h3>
<input type="text" name="content" maxlength="500" placeholder="Content" />
</div>
</div>
<div class="control-group">
<input type="checkbox" name="Ck_1" /> <label>Ck_1</label>//If selected then INSERT content into tbl_connect
<input type="checkbox" name="Ck_2" /> <label>Ck_2</label>//If selected then INSERT content into tbl_share
</div>
<div class="submit">
<input type="submit" value="Simplicity" />
</div>
PHP CODE:
<?php
//Define Content, Post & Share
$content=$_POST['content'];
$post=$_POST['ck_1'];
$share=$_POST['ck_2'];
//Insert into the db
$sql_post="INSERT INTO $tbl_connect (wall) VALUES ('$connect', '$post')";
$sql_share="INSERT INTO $tbl_share (wall) VALUES ('$connect', '$share')";
//Make sure it insert into db
$result_post = mysql_query($sql_post);
$result_share = mysql_query($sql_share);
if($result_post){
header("location:alert.php");
}else{
header("location:error.html");
}
if($result_share){
header("location:http://www.google.com");
}else{
header("location:error.html");
}
?>
Just keep it simple:
//Define Content, Post & Share
$content = $_POST['content']; // you should sanitize this to prevent SQL injection
if ( !empty($_POST['ck_1']) ) {
$sql_post = "INSERT INTO `tbl_connect` (wall) VALUES ('$connect')"; // if you have more than one value, then you need to specify more than one column...
}
if ( !empty($_POST['ck_2']) ) {
$sql_share = "INSERT INTO `tbl_share` (wall) VALUES ('$connect')";
}