Refresh page give difference style result after adding form element - php

I found a strange behaviour in my css style. I created a login page that can be accessed from a link wihtin home page. If I access login page from a link within home page or login page itself, everything looks fine. But, whenever I refresh login page, the header looks weird. And all of this happen only if <form> element is exists, without <form> element, there's no problem.
So, what causes this to happen? And how do I fix this?
Note: Everything after this is only attachment for my question details.
The login file page written like this:
<?php require_once($_SERVER['DOCUMENT_ROOT'].'/config/core.php'); ?>
<html>
<?php include_once($root.'/includes/head.php');?>
<body>
<div id="wrapper">
<?php include_once($root.'/includes/header.php');?>
<?php include_once($root.'/includes/navigation.php');?>
<section>
<article>
<h2>Login</h2>
<form action="<?php echo $current_file;?>" method="post">
<table align="center" border="0" cellpadding="0" cellspacing="15">
<tr>
<td width="100">Username</td>
<td>:</td>
<td><input type="text" name="username" maxlength="50" size="35"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input type="password" name="password" maxlength="50" size="35"></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" value=" Login "><input type="submit" value=" Reset "></td>
</tr>
</table>
</form>
</article>
</section>
<?php include_once($root.'/includes/news.php');?>
<?php include_once($root.'/includes/footer.php');?>
</div>
</body>
</html>
The header.php file that I included written like this:
<header>
<div id="logo">
<img src="/images/arh.png" />
<h1>The Header</h1>
</div>
</header>
And, the css file for header element is written like this:
header {
background-color: #000; height: 120px;
}
#logo {
float: left;
}
#logo img {
height: 100px; padding: 10px;
}
#logo h1 {
color: #ccc; float: right; font-size: 36px; padding: 30px;
}
The result if i access login.php page from link:
And, if i refresh the page:

i had pretty much that same problem. Matewka is right.
there was a small error in my html on my header. i had my div in the middle of my table.
What i had
<div>
<table>
<tr>
<td>
</td>
</tr>
</div>
</table>
what i changed it to
<div>
<table>
<tr>
<td>
</td>
</tr>
</table>
</div>
I just moved my div to the end of my table. I don't know how i did this, but being up for a few days or staring at the same thing over and over you start missing things. I would double check the html, it might be that simple. (are you using height % ?) do you have borders?

Related

Blade view not rendering in laravel

I am developing a website where candidate entry has to be done and record search.
I have created a single Blade view file. In which there are different section which are called based on the if condition.
My Display.blade.php view is as below
<center>
#if($ID>0)
<table border="0" width="100%">
<tr>
<td>#include('Header')</td>
</tr>
<tr>
<td style="font-family:arial;font-size:30px;text-align:center;">Edit Registration</td>
</tr>
</table>
#endif
<!--First Call-->
#if($ID < 0)
<table border="0" width="100%">
<tr>
<td>#include('Header')</td>
</tr>
<tr>
<td style="font-family:arial;font-size:30px;text-align:center;">New Registration1</td>
</tr>
</table>
<form action="/Register" method="post" target="_self">
<input type = "hidden" name = "_token" value = "<?php echo csrf_token() ?>">
<table border="1" width="70%" cellpadding="3" style="border-collapse: collapse" bordercolor="#eeeeee">
<tr>
<td>First Name</br><input type="text" name="fname" /></td>
<td>Middle Name</br><input type="text" name="mname" /></td>
<td>Last Name</br><input type="text" name="lname" /></td>
<td>Contact No</br><input type="text" name="contactno" /></td>
</tr>
<tr>
<td colspan="4" align="center"><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
#endif
</center>
Header.blade.php is as below.
<style>
.container
{
background-image: url("header.jpg");
background-repeat: repeat-all;
left:0;
top:0;
width:100%;
height:80px;
}
</style>
<div class="container">
<div class="Cname">Cube Placement</div>
<div class="rTable">
<div class="rTableRow">
<div class="rTableHead">
<strong>
<a href='{!!url('/Register'); !!}'>Register</a>
</strong></div>
<div class="rTableHead"><strong>Report</strong></div>
</div>
</div>
</div>
the code execute fine. When Edit Registration section is executed CSS is missing from the page but when New Registration section is called CSS works fine.
except that everything is working correctly.
What is wrong in my code.
To make your css accessible on every page, place the css file in a folder in the public folder and use this code in the link tag where you call the css file, preferably in the file you load on every page.
{{ URL::to('/') }}/path/style.css
Here you say to the browser go to yourdomain.com/path/style.css
Hope it works for you

Form doesn't submit all fields

I have a pretty huge form which I am able to extend dynamically with JavaScript. In this form I am having different DataSets with about 50 fields to submit each. When I submit the form I am running through a for loop from 0 to 100 to check which fields are set. So I create the HTML like this:
<form id = "formUpdate" role="form" action="index.php?action=update" method="post">
<table id="table" class="table table-hover"><thead>
<tr>
<th> Head1
<th> Head2
<th> Head3
<th> Head4
<th> Head5
<th> Head6
<th> ...
<tbody>
<?php
for ($i=0;$i<$dataSets;$i++){ ?>
<tr>
<td style="text-align: center; vertical-align: middle;"><label><?php echo $test[$i]['1']; ?> </label></td>
<td style="text-align: center; vertical-align: middle;"> <input required class="form-control formsUser" form="formUpdate" name="fieldA<?php echo $test[$i]['2']; ?>" value=""></input>
<td style="text-align: center; vertical-align: middle;"> <textarea style="height:34px" class="form-control formsUser" form="formUpdate" name="fieldB<?php echo $test[$i]['3'];?>" required></textarea>
<td style="text-align: center; vertical-align: middle;"> <input class="form-control formsUser" form="formUpdate" name="fieldC<?php echo $test[$i]['4']; ?>" required value=""></input>
<td style="text-align: center; vertical-align: middle;"> <input class="form-control formsUser" form="formUpdate" name="fieldD<?php echo $test[$i]['5']; ?>" required value=""></input>
<td style="text-align: center; vertical-align: middle;"> <input class="form-control formsUser" form="formUpdate" name="fieldE<?php echo $test[$i]['6']; ?>" value=""></input>
</tr>
<?php } ?>
</table>
<button class="btn btn-success" form="formUpdate" type="submit"> Submit </button>
</form>
PHP:
public function update(){
print_r($_REQUEST);
for ($i=0;$i<100;$i++){
$string = "fieldA".$i;
if (isset($_POST[$string])){
// set the other _POSTS
}
else {
//do something different
}
}
}
But this works only for the first 10 Datasets. When I call print_r($_REQUEST); it also just contains the content of the fields of the first 10 Datasets. I read about the limit of max_input_vars in the php.ini and increased this value, but nothing has changed. Besides I shouldn't reach the default value of 1,000 with my data. I also tried changing the value of max_input_nesting_level, memory_limit and post_max_size.
OMG. Got the Problem. I am using DataTables and when submitting the form, the table is redrawed showing the first 10 Datasets only...sorry for that guys and thanks for your help :)

How to display php code and html tags as text in a web page

I have the following piece of code and wish to display it as text in a webpage. How can I do it? I wat the code mentioned below to be displayed as text in a webpage. The page might be either a .html page or a .php page. Kindly help.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Log in!</title>
<style type="text/css">
div {
width:300px;
height:120px;
margin: 0px auto;
margin-top: 100px;
padding: 30px 20px;
border:2px solid #00F;
background-color:#0CF;
border-radius:10px;
}
span{
margin:0px auto;
color:#F00;
font-family:Verdana, Geneva, sans-serif;
font-size:12px;
}
</style>
</head>
<body>
</body>
<?php
require_once('conn.php');
$sql="select * from contacts where contacts_id=14";
$result=$mysqli->query($sql);
$row=$result->fetch_array();
if( isset($_POST['id']) && $row['email']==$_POST['id'] && $_POST['password']==$row['password'])
{
header("location:view.php") ;
$_SESSION['sid']= $row['email'];
$flag=1;
}
?>
<div>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table align="center" border="0">
<tr>
<td>Id</td>
<td>:</td>
<td><input type="text" name="id" placeholder="Email" /></td>
</tr>
<tr>
<td>Password</td>
<td>&:</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td></td>
<td colspan="2"><input type="submit" value="Log In!" /></td>
</tr>
</table>
</form>
<?php
if (isset($_POST['id']) && isset($_POST['password']) && $flag==0)
{
echo "<center><span>Invalid Id/Password</span></center>";
}
?>
</div>
</body>
</html>
You can also use highlight_string()
function
<?php
highlight_string("YOUR STRING/CODE GOES HERE");
?>
$gen_query_data= htmlspecialchars(' $'.$db_val_clean.'_ser = $_POST["'.$sel_name_clean.'_ser"];')."<br>";
echo $gen_query_data;
please change your variables
if your server isn't set up to process .html for the php tag, you're fine to do exactly what you've done.
You can also use this: <?php which would render as <?php but not be seen by PHP.
One option you can use is PHP's highlight_file() function:
<?php
highlight_file("your_file.php");
?>
You can also use .html file extensions highlight_file("your_file.html").
Even a .txt file extension highlight_file("your_file.txt").
Consult:
http://php.net/manual/en/function.highlight-file.php
this question is pretty old , but as long as no one used this solution so this would be helpful .
using htmlspecialchars :
htmlspecialchars — Convert special characters to HTML entities
echo htmlspecialchars("your special character goes here");

Jquery not adding dynamic php

I have a basic form that submits the form data to the same page and do a simple search in a MySQL db. The php for this in before the <html> tag
<body>
<div data-role="page">
<div role="main" class="ui-content">
enter code here
<table style="width:750px;">
<form enctype="multipart/form-data" action="player_documents_m.php" method="get" data-ajax="false">
<tr style="height:35px;">
<td style="width:250px; vertical-align:top; text-align:left;">
<label for="name">Player Name: </label>
</td>
<td style="text-align:left; vertical-align:middle; text-align:center;">
<input type="text" name="name" id="name" class="inputs" size="45" value="<?php echo $my_name; ?>" maxlength="255"/>
</td>
</tr>
<tr style="height:35px;">
<td style="text-align:left; vertical-align:bottom; text-align:right;" colspan="2">
<input type="submit" name="search" id="search" value="Search Player" />
</td>
</tr>
</form>
</table>
The above works in JqueryMobile
Then the results are added dynamically with html content but this does not work in JqueryMobile but taking out all JQueryMobile related stuff and leave a normal php page everything works.
Below the table tag above I add my php to add the founded search results.
<?php
for($j = 0; $j < $i; $j++)
{
$photo = "images/" . $db_new . "/players/" . $player[$j]["player_id"] . ".jpeg";
echo "<br />";
?>
<!-- Search Results -->
<div class="singleResult" onclick="javascript: window.location.replace('load_documents.php?identification=<?php echo $player[$j]["player_id"]; ?>');">
<table border="1" style="width:100%; border: solid thin; padding:0; border-spacing:0;">
<tr>
<!-- Image 1st Column -->
<td rowspan="2" colspan="1" style="width:10%; vertical-align:top; text-align:left;">
<img src="<?php echo $photo; ?>" style="width:150px; height:180px;" />
</td>
<td class="labels">Name:
<p class="results"><?php echo $player[$j]["player_name"]; ?></p>
</td>
</tr>
</table>
</div>
<!-- End Of Search Results -->
<?php
}
?>
</div>
</div>
</body>
Now the above only works normally and not in JqueryMobile. can some please explain to me what I am doing wrong / need to add, or anything helpful please.
Thanks

ReCaptcha doesn't show up on Facebox

<?php
session_start();
require_once('recaptcha/recaptchalib.php');
$publickey = "API_KEY"; // you got this from the signup page
?>
<script type="text/javascript" src="javascripts/jquery.form.js"></
script>
<script type="text/javascript">
$(document).ready(function() {
$('#inquiry').ajaxForm({
target: '#error',
success: function() {
$('#error').fadeIn('slow');
}
});
});
var RecaptchaOptions = {
theme : 'clean'
};
</script>
<div class="top_area">Inquiry Form</div>
<div id="search_area">
</div>
<div style="overflow-y: hidden;">
<form name="inquiry" id="inquiry" action="asadadasd.php"
method="post">
<div id="error"></div>
<table align="center">
<tr>
<td valign="top" align="right"></td>
<td>
<?php
echo recaptcha_get_html($publickey);
?>
</td>
</tr>
<tr>
<td valign="top"></td>
<td>
<input type="submit" id="submit" name="submit" value="Submit"
style="height: 30px; background: #ab2220; border: 2px #fff solid;
color: #fff;" />
</td>
</tr>
</table>
</form>
</table>
</form>
</div>
That's the code I have as of now but recaptcha plugin doesn't show up
am I missing something?
Thanks guys,
You are so awesome
You have to use the recaptcha AJAX API on facebox. Include the AJAX script in your page (Not the page facebox will display. Put it in the containing page) Then use the recaptcha api as specified in the docs.
http://code.google.com/apis/recaptcha/docs/display.html#AJAX

Categories