I am getting these errors in the browser
"Response must contain the AMP-Access-Control-Allow-Source-Origin
header"
and
"Form submission failed: Error: Response must contain the
AMP-Access-Control-Allow-Source-Origin header"
php
<?php
if (isset($_POST['iletisimg'])) {
$status = 0;
$ip = $_SERVER['REMOTE_ADDR'];
$time = time();
if (empty($post->isim) || empty($post->mesaj) || empty($post->email)) {
$yorumcevap = "Lütfen tüm alanları eksiksiz doldurunuz!";
} else {
$yorumekle = $db->query("insert into iletisim (isim,mesaj,email,konu,durum,tarih,ip) values ('$post->isim', '$post->mesaj', '$post->email', '$post->konu', 0, '$time', '$ip')");
if ($yorumekle) {
$yorumcevapok = "Teşekkürler. Talebiniz alındı.";
} else {
$yorumcevap = "Hata! Lütfen tekrar deneyin.";
}
}
}
html
<html amp lang="tr">
<head>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
</head>
<body>
<form method="post" action-xhr="#" autocomplete="off">
<?PHP echo '<p>' . $yorumcevap . '</p>'; ?>
<input type="text" class="isim" name="isim" autofocus required>
<input type="text" class="isim" name="konu" required>
<input type="text" class="isim" name="email" required>
<textarea name="mesaj" cols="80" rows="8" required></textarea>
<input type="submit" value="Gönder" name="iletisimg">
</form>
</body>
</html>
How can I edit it this to avoid those errors ?
You need to ensure that your CORS settings meet the AMP requirements as documented here
There's also a similar question which provides the code on how to set the response headers properly:
AMP Access Control Allow Source Origin header Issue
Related
i am new to php I am trying to write a registration page.But something goes wrong.Every time i try to execute the code i get something like this in my page
Database details
Db name: cibil,
table name: table {id,username,password,email
}
query($sql)===true) { $_SESSION['message']='You are successfully added';
$_SESSION['username']=$user; $_SESSION['email']=$email;
header(location:page.php); } else{ $_SESSION['message']='Something went wrong'; } } ?>
My code is
<? php
session_start()
$_SESSION['message']='';
if($_SERVER['REQUEST_METHOD']=='POST')
{
$conn=new mysqli('localhost','root','','cibil') or die("error");
$user=$_POST['user'];
$pass=$_POST['pass'];
$email=$_POST['email'];
$sql="INSERT INFO table (username, password,email)VALUES('$user','$pass','$email')";
if($conn->query($sql)===true)
{
$_SESSION['message']='You are successfully added';
$_SESSION['username']=$user;
$_SESSION['email']=$email;
header(location:page.php);
}
else{
$_SESSION['message']='Something went wrong';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Register form</title>
<link rel="stylesheet" type="text/css" href="reg_style.css">
</head>
<body>
<div id="h1">
<h1>Registration Page</h1>
</div>
<div id="err"><? php echo $_SESSION['message'] ?></div>
<div id='form'>
<form method="post" name='form' onsubmit="return rvalidate()" action="">
<p class="error">*Required</p>
<label for="user">Enter Your Name* : </label>
<input id="user" type="text" name="user" class="field">
<span class='error'></span><br><br>
<label for="email">Enter Your Email : </label>
<input id="email" type="text" name="email" class="field">
<br><br>
<label for="pass">Enter Your Password* : </label>
<input type="password" id="pass" name="pass" class="field"><span class='error'></span><br><br>
<label for="rpass">Re-Enter Your Password* : </label>
<input type="password" id="rpass" name="rpass" class="field"><span class='error'></span><br><br>
<input type="submit" id='submit' class="field" value="SUBMIT" onclick="validate();" >
</form>
</div>
<br><br>
<div id="login_text">
<b>If you are already register </b><br>Click here
</div>
<script type="text/javascript">
var error=document.getElementsByTagName('span');
var user=document.form.user;
var pass=document.form.pass;
var rpass=document.form.rpass;
function validate()
{
if(user.value==="")
{
error[0].innerHTML="*Enter Your name";
user.setAttribute("style","border-color:green");
}else{
error[0].innerHTML="";
user.setAttribute("style","border-color:initial");
}
if(pass.value=="")
{
error[1].innerHTML="*Password is Required";
pass.setAttribute("style","border-color:green");
}else{
error[1].innerHTML="";
pass.setAttribute("style","border-color:initial");
}
if(pass.value!==rpass.value)
{
error[2].innerHTML="*Password Missmatch";
rpass.setAttribute("style","border-color:green");
}else{
error[2].innerHTML="";
rpass.setAttribute("style","border-color:initial");
}
}
function rvalidate()
{
if (error[0].innerHTML=="" && error[1].innerHTML=="" && error[2].innerHTML=="") {
return true;
}
else{
return false;
}
}
</script>
</body>
</html>
Thank you for your help.........
Your code is not executed and shown as text because you have a space between ? and php at the start of the code. Try to start with <?php
session_start();. Then you will be able to debug all the rest :)
<div id="err"><? php echo $_SESSION['message']
If you notice there is a space between the ? And PHP, that may affect what is bring output. There is a few areas where your quotes don't match so if you check if the quotes aren't closing each other in places they shouldn't be closed then you should be okay
Is your filename correct? If it is a .htm or .html file it may not parse the PHP which could also be another issue you're having
You have a space at the opening of your php code :
<? php
should be :
<?php
Your code:
$sql="INSERT INFO table (username, password,email)VALUES('$user','$pass','$email')";
Must be without `...`:
$sql="INSERT INFO table (username, password,email)VALUES($user, $pass, $email)";
<html>
<head>
<!-- SCRIPTS -->
<script type="text/javascript" src="scripts/controller.js"></script>
<!-- STYLES -->
<link href="styles/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
$errUrl = $videoId = "";
$start = $end = 0;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
print_r($_POST);
if (isset($_POST["yt_url"])) {
echo "hello2";
$videoId = youtube_parser($_POST['yt_url']);
}
if (!$videoId) {
$errUrl = "URL is not valid!";
$videoId = "";
} else {
$errUrl = "";
}
//$start = $_POST['startH'] * 3600 + $_POST['startM'] * 60 + $_POST['startS'] * 1;
//$end = $_POST['endH'] * 3600 + $_POST['endM'] * 60 + $_POST['endS'] * 1;
}
function youtube_parser($url) {
$regExp = '/^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$/';
$match = preg_match($regExp, $url, $matches);
return ($match && strlen($matches[5]) === 11)? $matches[5] : false;
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<div class="left">
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<span class="error">* <?php echo $errUrl; ?></span><br>
URL: <input type="text" name="yt_url">
<br><br>
Start Time:<br>
<span class="label">Hour: </span><input value="0" type="number" name="start_h"><br>
<span class="label">Minute: </span><input value="0" type="number" name="start_m"><br>
<span class="label">Second: </span><input value="0" type="number" name="start_s">
<br><br>
End Time:<br>
<span class="label">Hour: </span><input value="0" type="number" name="end_h"><br>
<span class="label">Minute: </span><input value="0" type="number" name="end_m"><br>
<span class="label">Second: </span><input value="0" type="number" name="end_s">
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
</div>
<div class="player"><?php
if (isset($videoId) && !empty($videoId)) {
echo '<iframe width="560" height="315" src="https://www.youtube.com/embed/$videoId?start=$start&end=$end" frameborder="0" allowfullscreen></iframe>';
}
?></div>
</body>
</html>
The above is what I have so far. I am attempting to learn php, and I have been working through the tutorials on w3schools I got to the part about working with forms, and none of the information is being passed in the $_POST array, I have set names for all of my DOM controls. Any insight would be greatly appreciated! I have a feeling it my have something to do with my PHP setup as even the provided example doesn't work.
Additional Information:
Web server running through Intellij PHPStorm.
php version is 7.0.9
Your code looks valid and when I tried it it shows expected output from $_POST array:
So it looks like you got problems with environment you are testing it on.
BTW <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
is wrong. Aside from spaghetti code, you should not use htmlspecialchars() here but urlencode()
(yet I'd use nothing _SERVER['PHP_SELF'] cannot be spoofed by client).
Also as #CarlJan suggested you may want to use isset($_POST['submit']) to check if your form was submitted as this will condition will only be true if your submit button is sent via POST. For now you are checking if this is POST request (in general) but it is not the same as it can be post from other form, or triggered by hand.
I tried to make a code which will add an entry to my MySQL table (called "rechnungen") via php. So I made some inputs in html and finaly I tried to insert the informations into my table (using the INSERT INTO... command). So this is what i made:
<?php
Session_Start();
$username=$_SESSION['username'];
$password=$_SESSION['password'];
$dbname=$_SESSION['dbname'];
$servername=$_SESSION['hostname'];
/*conn dev*/
$conn = mysql_connect($servername, $username, $password);
if($conn === false){
header("Location: LogIn.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title></title>
</head>
<body>
<main>
<form method="POST" action="">
<div class="form_neueRechnung">
<!-- part 1 -->
<input type="text" name="suche_Vname_Patienten" placeholder="Vorname" required="">
<input type="text" name="suche_Nname_Patienten" placeholder="Nachname" required="">
<input type="number" id="id_Patient" name="id_patient" placeholder="Pat. Nr." Value="
<?php echo $KID_output; ?>" required="">
</td>
<input type="radio" name="Behandlung" value="Osteopathie" onclick="andere()" required="">
<input type="radio" name="Behandlung" value="Krankengymnastik" onclick="andere()" required="">
<input type="radio" name="Behandlung" id="andere_Behandlung" value="andere" onclick="andere()" required="">
<input type="text" name="andereBehandlung_text" id="andereBehandlung_text" placeholder="andere" style="visibility:hidden">
<!-- part 2 -->
<input type="radio" name="rezept_rechnung" id="mit_rezept" value="mit_Rezept" onclick="rezept()" required="">
<input type="radio" name="rezept_rechnung" id="ohne_rezept" value="ohne_Rezept" onclick="rezept()" required="">
<input type="text" id="ohne_rezept_text" name="ohne_rezept_text" placeholder="freier Text">
<!-- part 3 -->
<input type="time" name="termin1_von" required="">
<input type="time" name="termin1_bis" required="">
<input type="date" name="termin1_date" required="">
<!-- submit -->
<input type="submit" class="submit" value="Rechnug erstellen" name="submit" id="submit">
</div>
<div class="form_fieldset" id="rezept_einstellungen" style="visibility:hidden">
<input type="date" id="rezept_datum" name="rezept_datum">
<input type="text" id="rezept_verordnung" name="rezept_verordnung">
<input type="text" id="rezept_diagnose" name="rezept_diagnose">
</div>
</form>
<script type="text/javascript">
function andere() {
if (document.getElementById('andere_Behandlung').checked) {
document.getElementById('andere_BehandlungArt').style.visibility = 'visible';
} else {
document.getElementById('andere_BehandlungArt').style.visibility = 'hidden';
}
}
function rezept() {
if (document.getElementById('mit_rezept').checked) {
document.getElementById('rezept_einstellungen').style.visibility = 'visible';
} else {
document.getElementById('rezept_einstellungen').style.visibility = 'hidden';
}
if (document.getElementById('ohne_rezept').checked) {
document.getElementById('ohne_rezept_text').style.visibility = 'visible';
} else {
document.getElementById('ohne_rezept_text').style.visibility = 'hidden';
}
}
</script>
<?php
mysql_connect("$servername","$username","$password") or die("connection failed!");
mysql_select_db($dbname) or die ("no database found");
$query = mysql_query("SELECT * FROM `rechnungen`");
while($row = mysql_fetch_array($query)){
$RID = $row['RechnungsID'];
}
$RechnungsID = max($RID ,$RID)+1;
echo $RechnungsID;
$mit_ohne_Rezept = "";
if(isset($_POST['submit'])) {
if($_POST['rezept_rechnung'] == "mit_Rezept") {
$mit_ohne_Rezept = "1";
}
else {
$mit_ohne_Rezept = "0";
}
}
if(isset($_POST['submit'])){
$KundenID=$_POST['id_patient'];
$Behandlung=$_POST['Behandlung'];
$Rezept_datum=$_POST['rezept_datum'];
$Rezept_Verordnung=$_POST['rezept_verordnung'];
$Rezept_Diagnose=$_POST['rezept_diagnose'];
$ohneRezept_text=$_POST['ohne_rezept_text'];
mysql_select_db($dbname,$conn);
$result = "INSERT INTO rechnungen (`RechnungsID`, `KundenID`, `Behandlung`, `mit_ohne_Rezept`, `Rezept_datum`, `Rezept_Verordnung`, `Rezept_Diagnose`, `ohneRezept_text`)
VALUES ('$RechnungsID','$KundenID','$Behandlung','$mit_ohne_Rezept','$Rezept_datum','$Rezept_Verordnung','$Rezept_Diagnose','$ohneRezept_text)";
if (mysql_query($result)) {
echo ("finished!");
} else {
echo "error". mysql_error();
}
}
mysql_close($conn);
?>
</main>
</body>
</html>
I know it's a pretty long code, but i don't know where the problem could be. I'm getting this error:
errorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''sdfas)' at line 2
please help me. I'm despairing.
','$ohneRezept_text)";
looks like the issue is here.
missing a quotation mark?
that's what the error is saying
also you don't need to wrap variables in quotations, well you can but its still a pain. if your input contains quotation marks it skips right out. Use addslashes()
I've written a PHP script for user login and I validate it using 2 users namely "test" and "admin". When the username and password is matched I redirect the page to UploadFile.php and DownloadFile.php. Though my script validates test and admin users by displaying the echo stmt present in the block, redirect is not working. What mistake have i done or should i follow any other method?
<!DOCTYPE html>
<html lang="en" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8" />
<title>Login Page</title>
</head>
<body>
<h1>PHP & MySQL File Upload & Download </h1>
<br><br><br>
<form autocomplete="on" method="post">
<h1>Log in</h1>
<p>
<label for="userName" class="uname" data-icon="u" > Your email or username </label>
<input id="userName" name="userName" required="required" type="text" placeholder="myusername or mymail#mail.com"/>
</p>
<p>
<label for="userPass" class="youpasswd" data-icon="p"> Your password </label>
<input id="userPass" name="userPass" required="required" type="password" placeholder="eg. X8df!90EO" />
</p>
<p class="keeplogin">
<input type="checkbox" name="loginkeeping" id="loginkeeping" value="loginkeeping" />
<label for="loginkeeping">Keep me logged in</label>
</p>
<p class="login button">
<input type="submit" value="Login" id="sign" name="sign"/>
</p>
<p class="change_link">
Not a member yet ?
Join us
</p>
</form>
</body>
</html>
<?php
if (isset($_POST['sign'])) {
$uname = test_input($_POST["userName"]);
$upass = test_input($_POST["userPass"]);
if ((strcmp($uname, "test") == 0) && (strcmp($upass, "test") == 0)) {
header("Location: UploadFile.php");
echo "test user";
} else if ((strcmp($uname, "admin") == 0) && (strcmp($upass, "admin") == 0)) {
header('Location: DownloadFile.php');
echo "admin user";
} else {
echo "<script>
alert('Login Failed');
</script>";
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
Put the PHP code in front of the HTML code.
Calls to header() have to be placed before outputting anything! You are outputting lots of html before.
See any of these results for further information: https://www.google.de/search?q=headers+already+sent
You can't output headers after starting the body of the response. Try moving your PHP block to before the HTML begins.
On a side note, the fact that PHP isn't telling you this suggests your error reporting isn't verbose enough - you should see a warning similar to the one in this question. Try putting error_reporting(-1); at the top of your code, or changing the setting in php.ini.
Generally speaking, I agree with the usage of header() as a proper redirection mechanism (and, with the exception of the javascript you're injecting, you could move the entire PHP code block above the HTML to get the desired effect)
However, if you'd like to display some content for a short period of time (let's say 2 seconds) before performing the redirect, consider using the "meta-refresh" method, described here:
http://www.w3.org/TR/WCAG20-TECHS/H76
For example, in your current code, try changing:
header("Location: UploadFile.php");
to:
echo "<meta http-equiv=\"refresh\" content=\"2;URL='UploadFile.php'\" />";
Although the W3C page says you should place this element inside the "head" element, practical experience shows that the vast majority of browsers will respect your intentions of showing content then redirecting after the specified time interval.
If you decide to use this "meta" element and move your PHP code to the top of the file, I suggest plugging values in accordingly instead of echoing them immediately:
<?php
$meta_element = '';
$login_message = '';
if (isset($_POST['sign'])) {
$uname = test_input($_POST["userName"]);
$upass = test_input($_POST["userPass"]);
if ((strcmp($uname, "test") == 0) && (strcmp($upass, "test") == 0)) {
$meta_element = "<meta http-equiv=\"refresh\" content=\"2;URL='UploadFile.php'\" />";
$login_message = "test user";
} else if ((strcmp($uname, "admin") == 0) && (strcmp($upass, "admin") == 0)) {
$meta_elementt = "<meta http-equiv=\"refresh\" content=\"2;URL='DownloadFile.php'\" />";
$login_message = "admin user";
} else {
$login_message = "<script>
alert('Login Failed');
</script>";
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<!DOCTYPE html>
<html lang="en" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8" />
<title>Login Page</title>
<?php echo $meta_element; ?>
</head>
<body>
<h1>PHP & MySQL File Upload & Download </h1>
<br><br><br>
<form autocomplete="on" method="post">
<h1>Log in</h1>
<?php echo $login_message; ?>
<p>
<label for="userName" class="uname" data-icon="u" > Your email or username </label>
<input id="userName" name="userName" required="required" type="text" placeholder="myusername or mymail#mail.com"/>
</p>
<p>
<label for="userPass" class="youpasswd" data-icon="p"> Your password </label>
<input id="userPass" name="userPass" required="required" type="password" placeholder="eg. X8df!90EO" />
</p>
<p class="keeplogin">
<input type="checkbox" name="loginkeeping" id="loginkeeping" value="loginkeeping" />
<label for="loginkeeping">Keep me logged in</label>
</p>
<p class="login button">
<input type="submit" value="Login" id="sign" name="sign"/>
</p>
<p class="change_link">
Not a member yet ?
Join us
</p>
</form>
</body>
</html>
I have a process.php file for processing a comment/message form. If there is an error during the processing, the incorrect form content is echoed and shown as a web page named process.php to the viewer for correction and resubmitting.
The problem is that I need the echoed content to contain various <?php include("xxxx.php");?> elements so that it matches the rest of my site. But this seems to make the page fall over (showing blank page with no content). I've been told that I should use either include("xxxx.php"); or echo file_get_contents("xxxx.php"); from within the echoed content, but neither displays the intended content.
Any help in these issues would be greatly appreciated.
Code: (some items xxxxx for security)
<?php
// Information to be modified
$your_email = "xxxxxxxx#xxxxx.xx.xx"; // email address to which the form data will be sent
$subject = "Contact message"; // subject of the email that is sent
$thanks_page = "thankyou.htm"; // path to the thank you page following successful form submission
$contact_page = "mail_form_styled.php"; // path to the HTML contact page where the form appears
// Nothing needs to be modified below this line
if (!isset($_POST['submit'])) {
header( "Location: $contact_page" );
}
if (isset($_POST["submit"])) {
$nam = $_POST["name"];
$ema = trim($_POST["email"]);
$com = $_POST["comments"];
$spa = $_POST["spam"];
if (get_magic_quotes_gpc()) {
$nam = stripslashes($nam);
$ema = stripslashes($ema);
$com = stripslashes($com);
}
$error_msg=array();
if (empty($nam) || !preg_match("~^[a-z\-'\s]{1,60}$~i", $nam)) {
$error_msg[] = "The name field must contain only letters, spaces, dashes ( - ) and single quotes ( ' )";
}
if (empty($ema) || !filter_var($ema, FILTER_VALIDATE_EMAIL)) {
$error_msg[] = "Your email must have a valid format, such as name#mailhost.com";
}
$limit = 1000;
if (empty($com) || !preg_match("/^[0-9A-Za-z\/-\s'\(\)!\?\.,]+$/", $com) || (strlen($com) > $limit)) {
$error_msg[] = "The Comments field must contain only letters, digits, spaces and basic punctuation ( ' - , . ), and has a limit of 1000 characters. Website addresses can not be included.";
}
if (!empty($spa) && !($spa == "4" || $spa == "four")) {
echo "You failed the spam test!";
exit ();
}
// Assuming there's an error, refresh the page with error list and repeat the form
if ($error_msg) {
echo '<!DOCTYPE html>
<html lang="en">
<!-- Begin head items -->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1">
<meta name="description" content="The Dark Fortress contact form. Use it to get in touch…" />
<link href="../styles/screen.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml"
title="thedarkfortress Command Briefing"
href="http://feeds.feedburner.com/ThedarkfortressCommandBriefing" />
<title>O dear! | The Dark Fortress</title>
<style type="text/css">
.hide {display:none;}
</style>
</head>
<!-- Begin body items -->
<body>
<div id="container">
<!-- Begin header items -->
echo file_get_contents("../components/header.php");
<!-- Begin main content items -->
<div id="content-container">
<!-- Begin content items -->
<div id="content">
<h1>O dear!</h1>
<p>Unfortunately, your message could not be sent. The form as you filled it out is displayed below. Make sure each field completed, and please also address any issues listed below:</p>
<ul class="err">';
foreach ($error_msg as $err) {
echo '<li>'.$err.'/li>';
}
echo '</ul>
<form method="post" action="', $_SERVER['PHP_SELF'], '">
<label for="name">Name</label>
<input name="name" type="text" size="40" maxlength="60" id="name" value="'; if (isset($_POST["name"])) {echo $nam;}; echo '">
<label for="email">Email Address</label>
<input name="email" type="email" size="40" maxlength="60" id="email" value="'; if (isset($_POST["email"])) {echo $ema;}; echo '">
<label for="comm">Comments</label>
<textarea name="comments" rows="7" cols="50" id="comm">'; if (isset($_POST["comments"])) {echo $com;}; echo '</textarea>
<div class="hide">
<label for="spam">What is six plus four?</label>
<input name="spam" type="text" size="4" id="spam">
</div>
<input type="submit" name="submit" value="Send" class="button orange send" />
</form>
<div class="divider"><hr /></div>
<p><img src="../main_assets/isiah_page_sig_flat.png" alt="Isiah signature" /></p>
<p><strong>Chronicler Isiah,</strong> the 4th Battle Company, Dark Angels.</p>
</div>
<!-- Begin left nav items -->
<div id="leftnav">
echo file_get_contents("../components/hq_leftnav.php");
</div>
</div>
</div>
<!-- Begin footer items -->
echo file_get_contents("../components/footer.php");
<!-- Begin google analytics tracker items -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("xxxxxx"); pageTracker._trackPageview();
</script>
</body>
</html>';
exit();
}
$email_body =
"Name of sender: $nam\n\n" .
"Email of sender: $ema\n\n" .
"COMMENTS:\n\n" .
"$com" ;
// Assuming there's no error, send the email and redirect to Thank You page
if (isset($_REQUEST['comments']) && !$error_msg) {
mail ($your_email, $subject, $email_body, "From: $nam <$ema>" . "\r\n" . "Reply-To: $nam <$ema>");
header ("Location: $thanks_page");
exit();
}
}
You'd simply use CSS as you normally would...
<?php
// index.php
?>
<!doctype html>
<html>
<head>
<style type="text/css">
.myClass {
color: #f00;
}
</style>
</head>
<body>
<?php
include('myFile.php');
?>
</body>
</html>
<?php
// included myFile.php
echo '<p class="myClass">Echoed content!</p>';
If you're ending up with a blank page with no content then you potentially have errors in your PHP. Ensure error reporting is enabled and you'll be able to see what's going wrong.