Here is my code.My destination was: i will enter some content text(like articles), keywords and site url. And in the end keyword in text will be linked to url i was given for once.
But code doesnt work. So where is my mistakes?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>
</head>
<body>
<form name="form1" method="post" action="">
<div style="float:left">
<table width="40%" border="0" >
<tr>
<td height="30" class="yazi">Text</td>
<td height="30">:</td>
<td height="30">
<span class="formyazi"><textarea name="text1" cols="75" rows="25"></textarea><br></span>
</td>
</tr>
<tr>
<td width="23%" height="30" class="yazi">Keywords</td>
<td width="1%" height="30" class="style1">:</td>
<td width="76%" height="30">
<span class="formyazi"><input type="text" name="keywords" value=""></span>
</td>
</tr>
<tr>
<td width="23%" height="30" class="yazi">site adress</td>
<td width="1%" height="30" class="style1">:</td>
<td width="76%" height="30">
<span class="formyazi">http://<input type="text" name="site" value="">/</span>
</td>
</tr>
<tr>
<td height="55" colspan="3">
<input type="submit" class="button" style="font-size:10pt;color:#FFFFFF;border-style:solid;border-width:1;background-color:#0D78B3" value="Send!">
</td>
</tr>
</table>
</div>
</form>
<?php
$text2=$_POST["text1"];
$nesne=str_replace($keywords,'$keywords',$text2 ,1);
$linkedtext=$nesne;
?>
<div style="float:left">
<table width="40%" border="0" >
<tr>
<td height="30" class="yazi">Text with link</td>
<td height="30">:</td>
<td height="30">
<span class="formyazi"><textarea name="cikti" cols="75" rows="25"><?php echo $linkedtext;?></textarea><br></span>
</td>
</tr>
</table>
</div>
</body>
</html>
Since you've gotten the correct $_POST variables according to your comment, you need to fix this now
$nesne=str_replace($keywords,'$keywords',$text2 ,1);
You cannot put variables in a single-quote delimited string - use double quotes around it with single-quotes inside.
Like this:
$nesne=str_replace($keywords,"<a href='$link' title='$keywords' target='new'>$keywords</a>",$text2 ,1);
Related
Notice: Use of undefined constant login - assumed 'login' in C:\wamp\www\Online_exam\header.php on line 43
Notice: Use of undefined constant login - assumed 'login' in C:\wamp\www\Online_exam\header.php on line 47
Notice: Use of undefined constant login - assumed 'login' in C:\wamp\www\Online_exam\index.php on line 30
I am new to PHP and learning SESSION, and i am trying to explore on that and i am receiving the above errors. Everything looks correct for me. Please somebody help me.
Index.php
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Wel come to Online Exam</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="quiz.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
include("header.php");
include("database.php");
extract($_POST);
if(isset($submit))
{
$rs=mysql_query("select * from mst_user where login='$loginid' and pass='$pass'");
if(mysql_num_rows($rs)<1)
{
$found="N";
}
else
{
$_SESSION[login]=$loginid;
}
}
if (isset($_SESSION[login]))
{
echo "<h1 class='style8' align=center>Wel come to Online Exam</h1>";
echo '<table width="28%" border="0" align="center">
<tr>
<td width="7%" height="65" valign="bottom"><img src="image/HLPBUTT2.JPG" width="50" height="50" align="middle"></td>
<td width="93%" valign="bottom" bordercolor="#0000FF"> Subject for Quiz </td>
</tr>
<tr>
<td height="58" valign="bottom"><img src="image/DEGREE.JPG" width="43" height="43" align="absmiddle"></td>
<td valign="bottom"> Result </td>
</tr>
</table>';
exit;
}
?>
<table width="100%" border="0">
<tr>
<td width="70%" height="25"> </td>
<td width="1%" rowspan="2" bgcolor="#CC3300"><span class="style6"></span></td>
<td width="29%" bgcolor="#CC3333"><div align="center" class="style1">User Login </div></td>
</tr>
<tr>
<td height="296" valign="top"><div align="center">
<h1 class="style8">Wel come to Online Quiz</h1>
<span class="style5"><img src="image/paathshala.jpg" width="129" height="100"><span class="style7"><img src="image/HLPBUTT2.JPG" width="50" height="50"><img src="image/BOOKPG.JPG" width="43" height="43"></span> </span>
<param name="movie" value="english theams two brothers.dat">
<param name="quality" value="high">
<param name="movie" value="Drag to a file to choose it.">
<param name="quality" value="high">
<param name="BGCOLOR" value="#FFFFFF">
<p align="left" class="style5"> </p>
<blockquote>
<p align="left" class="style5"><span class="style7">Wel Come to Online
exam. This Site will provide the quiz for various subject of interest.
You need to login for the take the online exam.</span></p>
</blockquote>
</div></td>
<td valign="top"><form name="form1" method="post" action="">
<table width="200" border="0">
<tr>
<td><span class="style2">Login ID </span></td>
<td><input name="loginid" type="text" id="loginid2"></td>
</tr>
<tr>
<td><span class="style2">Password</span></td>
<td><input name="pass" type="password" id="pass2"></td>
</tr>
<tr>
<td colspan="2"><span class="errors">
<?php
if(isset($found))
{
echo "Invalid Username or Password";
}
?>
</span></td>
</tr>
<tr>
<td colspan=2 align=center class="errors">
<input name="submit" type="submit" id="submit" value="Login"> </td>
</tr>
<tr>
<td colspan="2" bgcolor="#CC3300"><div align="center"><span class="style4">New User ? Signup Free</span></div></td>
</tr>
</table>
<div align="center">
<p class="style5"><img src="images/topleft.jpg" width="134" height="128"> </p>
</div>
</form></td>
</tr>
</table>
</body>
</html>
Header.php
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
}
-->
</style>
<table border="0" width="100%" cellspacing="0" cellpadding="0" background="image/topbkg.jpg">
<tr>
<td width="90%" valign="top">
<!--You can modify the text, color, size, number of loops and more on the flash header by editing the text file (fence.txt) included in the zip file.-->
<div align="left"><object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000
codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,2,0
width=500
height=68>
<param name=movie value=image/fence.swf>
<param name=quality value=high>
<param name=BGCOLOR value=#000000>
<param name=SCALE value=showall>
<param name=wmode value=transparent>
<embed src=image/fence.swf
quality=high
pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash
width=500
height=68
bgcolor=#000000
scale= showall>
</embed>
</object></div></td>
<td width="10%">
<img border="0" src="image/topright.jpg" width="203" height="68" align="right"></td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#000000" background="img/blackbar.jpg">
<tr>
<td width="100%" align="right"><img border="0" src="image/blackbar.jpg" width="89" height="15"></td>
</tr>
</Table>
<Table width="100%">
<tr>
<td>
<?php "Hi ".$_SESSION[login]; ?>
</td>
<td>
<?php
if(isset($_SESSION[login]))
{
echo "<div align=\"right\"><strong> Home |Signout</strong></div>";
}
else
{
echo " ";
}
?>
</tr>
</table>
session variable should wrap with ' '...
change your session variable like this...
$_SESSION['session_var_name'];
and in your case it should..
$_SESSION['login']
You have to give the session name inside quotes only. Use
$_SESSION['login'] or $_SESSION["login"]
Non-numeric array key constants should be enclosed in quotes, either single or double. Otherwise, php thinks you are referring to a constant name. And since it's undefined, it falls back to guessing you just forgot the quotes...
That's why it works. And that's why the issue appears as a Notice. But in order to do away with it, change $_SESSION[login] to $_SESSION['login'].
Replace $_SESSION[login] into $_SESSION['login'] in all occurance of your code
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Wel come to Online Exam</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="quiz.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
include("header.php");
include("database.php");
extract($_POST);
if(isset($submit))
{
$rs=mysql_query("select * from mst_user where login='$loginid' and pass='$pass'");
if(mysql_num_rows($rs)<1)
{
$found="N";
}
else
{
$_SESSION['login']=$loginid;
}
}
if (isset($_SESSION['login']))
{
echo "<h1 class='style8' align=center>Wel come to Online Exam</h1>";
echo '<table width="28%" border="0" align="center">
<tr>
<td width="7%" height="65" valign="bottom"><img src="image/HLPBUTT2.JPG" width="50" height="50" align="middle"></td>
<td width="93%" valign="bottom" bordercolor="#0000FF"> Subject for Quiz </td>
</tr>
<tr>
<td height="58" valign="bottom"><img src="image/DEGREE.JPG" width="43" height="43" align="absmiddle"></td>
<td valign="bottom"> Result </td>
</tr>
</table>';
// exit;
}
?>
<table width="100%" border="0">
<tr>
<td width="70%" height="25"> </td>
<td width="1%" rowspan="2" bgcolor="#CC3300"><span class="style6"></span></td>
<td width="29%" bgcolor="#CC3333"><div align="center" class="style1">User Login </div></td>
</tr>
<tr>
<td height="296" valign="top"><div align="center">
<h1 class="style8">Wel come to Online Quiz</h1>
<span class="style5"><img src="image/paathshala.jpg" width="129" height="100"><span class="style7"><img src="image/HLPBUTT2.JPG" width="50" height="50"><img src="image/BOOKPG.JPG" width="43" height="43"></span> </span>
<param name="movie" value="english theams two brothers.dat">
<param name="quality" value="high">
<param name="movie" value="Drag to a file to choose it.">
<param name="quality" value="high">
<param name="BGCOLOR" value="#FFFFFF">
<p align="left" class="style5"> </p>
<blockquote>
<p align="left" class="style5"><span class="style7">Wel Come to Online
exam. This Site will provide the quiz for various subject of interest.
You need to login for the take the online exam.</span></p>
</blockquote>
</div></td>
<td valign="top"><form name="form1" method="post" action="">
<table width="200" border="0">
<tr>
<td><span class="style2">Login ID </span></td>
<td><input name="loginid" type="text" id="loginid2"></td>
</tr>
<tr>
<td><span class="style2">Password</span></td>
<td><input name="pass" type="password" id="pass2"></td>
</tr>
<tr>
<td colspan="2"><span class="errors">
<?php
if(isset($found))
{
echo "Invalid Username or Password";
}
?>
</span></td>
</tr>
<tr>
<td colspan=2 align=center class="errors">
<input name="submit" type="submit" id="submit" value="Login"> </td>
</tr>
<tr>
<td colspan="2" bgcolor="#CC3300"><div align="center"><span class="style4">New User ? Signup Free</span></div></td>
</tr>
</table>
<div align="center">
<p class="style5"><img src="images/topleft.jpg" width="134" height="128"> </p>
</div>
</form></td>
</tr>
</table>
</body>
</html>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
}
-->
</style>
<table border="0" width="100%" cellspacing="0" cellpadding="0" background="image/topbkg.jpg">
<tr>
<td width="90%" valign="top">
<!--You can modify the text, color, size, number of loops and more on the flash header by editing the text file (fence.txt) included in the zip file.-->
<div align="left"><object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000
codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,2,0
width=500
height=68>
<param name=movie value=image/fence.swf>
<param name=quality value=high>
<param name=BGCOLOR value=#000000>
<param name=SCALE value=showall>
<param name=wmode value=transparent>
<embed src=image/fence.swf
quality=high
pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash
width=500
height=68
bgcolor=#000000
scale= showall>
</embed>
</object></div></td>
<td width="10%">
<img border="0" src="image/topright.jpg" width="203" height="68" align="right"></td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#000000" background="img/blackbar.jpg">
<tr>
<td width="100%" align="right"><img border="0" src="image/blackbar.jpg" width="89" height="15"></td>
</tr>
</Table>
<Table width="100%">
<tr>
<td>
<?php
if(isset($_SESSION['login']))
{
print "Hi ".$_SESSION['login'];
}
?>
</td>
<td>
<?php
if(isset($_SESSION['login']))
{
echo "<div align=\"right\"><strong> Home |Signout</strong></div>";
}
else
{
echo " ";
}
?>
</tr>
</table>
I want to display this
http://www.bwbsv.de/bbsb/service/extern/standings.php?start=http://www.bwbsv.de/bbsb/service/extern/start.htm&end=http://www.bwbsv.de/bbsb/service/extern/end.htm&t=401
(this is just an example)
on a page of my wordpress site.
The start.htm contains
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="de" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Demonstration Tabellen-Integration</title>
<link rel="stylesheet" type="text/css"
href="http://www.bwbsv.de/bbsb/service/extern/demo.css" />
</head>
<body>
while the end.htm looks like
</body>
</html>
The "t=401" specifies what league to display.
What would be the best way to implement this into a page?
EDIT: I forgot somehing. The url of the start.htm and end.htm are stored localy while the standings.php isn't. the point of this is to have an up to date league table, whithout doing it manually.
EDIT 2: To clarify further:
The first link is just an example of how it should look like. It can be customized to fit the users needs with for example t=401 means the league with id=401. After customization it should look something like this
http://www.bwbsv.de/bbsb/service/extern/standings.php?start=http:/yourServer.com/start.htm&end=http://http:/yourServer.com/end.htm&t=123
This link provides an up to date league table of the league with id 123. The updates are not done by me, they are provided from the bwbsv page. I want to integrate this table into an normal page/widget/sidebar/... on my wordpress site.
As I mentioned in my first post, due to the Same origin policy you cant load external content, sorry.
Use jQuery load()
Give the table an id of league-table and then:
$('#league-table').load('path/to/your_file');
Here is a working example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="de" xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<title>Demonstration Tabellen-Integration</title>
<link rel="stylesheet" type="text/css"
href="http://www.bwbsv.de/bbsb/service/extern/demo.css" />
</head>
<body>
<script type="text/javascript">
console.log("here");
$(document).ready(function(){
console.log("here");
$('#league').load('path_to_your_file.html');
alert("finished loading");
});
</script>
<div id="league">
</div>
</body>
</html>
File.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="de" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Demonstration Tabellen-Integration</title>
<link rel="stylesheet" type="text/css"
href="http://www.bwbsv.de/bbsb/service/extern/demo.css" />
</head>
<body>
<table id="league" class="standings">
<tbody><tr>
<th class="hpl">Pl.</th>
<th class="hteam">Team</th>
<th class="hg">G</th>
<th class="hv">V</th>
<th class="hpct">.pct</th>
<th class="hgb">GB</th>
</tr>
<tr>
<td class="pl">1.</td>
<td class="team">
Kehl Mosquitos
</td>
<td class="g">0</td>
<td class="v">0</td>
<td class="pct">.000</td>
<td class="gb">0</td>
</tr>
<tr>
<td class="pl">2.</td>
<td class="team">
Ulm Falcons
</td>
<td class="g">0</td>
<td class="v">0</td>
<td class="pct">.000</td>
<td class="gb">0</td>
</tr>
<tr>
<td class="pl">3.</td>
<td class="team">
Sindelfingen Squirrels
</td>
<td class="g">0</td>
<td class="v">0</td>
<td class="pct">.000</td>
<td class="gb">0</td>
</tr>
<tr>
<td class="pl">4.</td>
<td class="team">
Heidelberg Hedgehogs
</td>
<td class="g">0</td>
<td class="v">0</td>
<td class="pct">.000</td>
<td class="gb">0</td>
</tr>
<tr>
<td class="pl">5.</td>
<td class="team">
Schriesheim Raubritter
</td>
<td class="g">0</td>
<td class="v">0</td>
<td class="pct">.000</td>
<td class="gb">0</td>
</tr>
<tr>
<td class="pl">6.</td>
<td class="team">
Göppingen Green Sox
</td>
<td class="g">0</td>
<td class="v">0</td>
<td class="pct">.000</td>
<td class="gb">0</td>
</tr>
<tr>
<td class="pl">7.</td>
<td class="team">
Freiburg Knights
</td>
<td class="g">0</td>
<td class="v">0</td>
<td class="pct">.000</td>
<td class="gb">0</td>
</tr>
<tr>
<td class="pl">8.</td>
<td class="team">
Tübingen Hawks 2
</td>
<td class="g">0</td>
<td class="v">0</td>
<td class="pct">.000</td>
<td class="gb">0</td>
</tr>
<tr>
<td class="pl">9.</td>
<td class="team">
Neuenburg Atomics 2
</td>
<td class="g">0</td>
<td class="v">0</td>
<td class="pct">.000</td>
<td class="gb">0</td>
</tr>
</tbody></table>
</body>
</html>
Try with adding an iframe:
<iframe border="0" width="600px" height="auto" src="http://www.bwbsv.de/bbsb/service/extern/standings.php?start=http://www.bwbsv.de/bbsb/service/extern/start.htm&end=http://www.bwbsv.de/bbsb/service/extern/end.htm&t=401"></iframe>
You can change it's dimension for the best fit of the page.
i have a table named as item_request and it has twofields named as projectmanager and createddate which has the Timestamp format as 2012-09-11 17:46:25.
Now i want to call these two fields in another form which count the user entry between 2 different dates.and the date field is fetched from the timestamp.with this form i m sending the value through datetime picker having the format 10-12-2012 but the value in databse is in different format and the value i m sending is in diffferent format.how is it possible plzzz help me guys.
Here is the code for my form:
<?php
include("config.php");
ob_start();
error_reporting(0);
if(!isset($_SESSION[username]))
header("location: index.php");
if(isset($_POST[submit]))
{
$projectmanager=mysql_real_escape_string($_POST['projectmanager']);
$date=mysql_real_escape_string($_POST['date']);
$dateexp = explode("-",$date);
$date = mysql_real_escape_string($dateexp[0]."/".$dateexp[1]."/".$dateexp[2]);
$date1=mysql_real_escape_string($_POST['date1']);
$dateexp1 = explode("-",$date1);
$date1 = mysql_real_escape_string($dateexp1[0]."/".$dateexp1[1]."/".$dateexp1[2]);
echo $queryuser= "select * from item_request where projectmanager=$projectmanager AND (requireddate>=$date AND requireddate<=$date1)";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Project Managers Registrarion</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<script language="javascript" type="text/javascript" src="js/datetimepicker.js">
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
//For this script, visit http://www.javascriptkit.com
</script>
</head>
<body>
<div class="container">
<div class="header"><img src="images/cherry-new.jpg" width="79" height="93" />
<!-- end .header --></div>
<?php include("rightMenu.php");?>
<div class="content">
<h1>PR Count</h1>
<div style="padding:10px 0px; text-align:center; color:#990000;">
</div>
<form action="" method="post" name="loginform">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td>Project Managers</td>
<td><select name="projectmanager" style="width:145px;" id="projectmanager" onChange="showUser(this.options[this.selectedIndex].id)">
<option value="">Select</option>
<?php $queryuser= "select * from projectmanagers";
$fetuser1user = mysql_query($queryuser);
while($fetuser = mysql_fetch_array($fetuser1user)){
?>
<option id="<?php echo $fetuser['id']?>" value="<?php echo $fetuser['id']?>"><?php echo $fetuser['projectmanager']?></option>
<?php }
?>
</select></td>
</tr>
<tr>
<td>Date From</td>
<td>
<input id="date" type="text" size="20" name="date" /><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></td>
</tr>
<tr>
<td>Date To</td>
<td>
<input id="date1" type="text" size="20" name="date1"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="submit" id="submit" value="Submit" onClick="return formvalidate();"/>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
<table width="100%" border="1"><tr>
<td width="18%" valign="middle" class="tableheading">PI.No.</td>
<td width="18%" valign="middle" class="tableheading">Project Manager</td>
<td width="18%" valign="middle" class="tableheading">Date Created</td>
<td width="15%" valign="middle" class="tableheading">Action</td>
</tr>
<?php
// to print the records
$select = "select * from item_request";
$query1 = mysql_query($select);
while($value = mysql_fetch_array($query1)){ ?>
<tr>
<td class="tabletext"><?php echo $value[id];?></td>
<td class="tabletext"><?php echo $value[projectmanager];?></td>
<td class="tabletext"><?php echo $value[datefrom];?></td>
<td class="tabletext"><img src="images/edit.png" width="25" height="25" border="0" title="Edit" />
<img src="images/deleteBtn.png" width="25" height="25" border="0" title="Edit" /></td>
</tr><?php }?>
</table>
</form>
<!-- end .content --></div>
<?php include("footer.php");?>
<!-- end .container --></div>
</body>
</html>
Replace this function call...
javascript:NewCal('date','ddmmyyyy');
with this one...
javascript:NewCal('date','ddmmyyyy',true,24);
Hope it helps.
Below is a contact us script in php, when I click submit at www.mydomain.com.au/contact.html it looks as though it works because I end up at ww.mydomain.com.au/thanks.html.
However the specified email account is not receiving contact emails.
Here is the code for the contact us script found at includes/contact_mail.php
<?php
if(isset($_POST['enter']) && $_POST['enter']==1)
{
$_SESSION['email']=$_POST['email'];
$to="name#domains.com";
$subject='Contact Us Details';
$message="<style>
.textstyle{
font-family:Tahoma;
font-size:11px;
color:#156E00;
text-align:left;
margin-left:10px;
text-decoration:none;
}
</style>";
$message.="<table width=400 border=0>
<tr><td class=textstyle>First Name: </td> <td class=textstyle>".$_POST['fname']."</td></tr>
<tr><td class=textstyle>Last Name: </td> <td class=textstyle>".$_POST['lname']."</td></tr>
<tr><td class=textstyle>E-mail: </td> <td class=textstyle>".$_POST['email']."</td></tr>
<tr><td class=textstyle>Phone Number: </td> <td class=textstyle>".$_POST['tel']."</td></tr>
<tr><td class=textstyle>Comments: </td> <td class=textstyle>".$_POST['que']."</td></tr>
</table>";
$mail_from = "From:".$_POST['email'];
$mail_from .="\r\nContent-type: text/html";
#mail($to,$subject,$message,$mail_from);
header("location: ../thankyou.html");
exit();
}
?>
Here is the code at ww.mydomain.com.au/contact.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="GENERATOR" content="Macromedia Dreamweaver CS3" />
<meta name="author" content="Relyon security" />
<meta name="keywords" content="Camera Surveillance,Spy Cameras,Remote Viewing,Audio recording,Relyon security" />
<meta name="description" content="" />
<meta http-equiv="EXPIRES" content="-1" />
<title>Relyon Security: About Relyon Security</title>
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
<script language="JavaScript" type="text/javascript">
function fullcheck()
{
var str=document.contact.email.value;
//alert(str);
if (document.contact.fname.value=="")
{
alert ("Blank space not allowed. Please type your First Name.");
document.contact.fname.select();
return false;
}
if (document.contact.lname.value=="")
{
alert ("Blank space not allowed. Please type your Last Name.");
document.contact.lname.select();
return false;
}
if ((document.contact.email.value).indexOf(" ")>=0)
{
alert ("Blank space not allowed inside email!");
document.contact.email.select();
return false;
}
if (document.contact.email.value.indexOf("#",1) == -1)
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if (document.contact.email.value.indexOf("#") == 0)
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if (document.contact.email.value.indexOf(".",5) == -1)
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if (document.contact.email.value.indexOf(".") == 0)
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if ((document.contact.email.value.lastIndexOf(".")) -(document.contact.email.value.indexOf("#"))<4 )
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if (document.contact.tel.value=="")
{
alert ("Blank space not allowed. Please type your Telephone Number.");
document.contact.tel.select();
return false;
}
if (document.contact.que.value=="")
{
alert ("Blank space not allowed. Please enter your question or comment.");
document.contact.que.select();
return false;
}
}
//-->
</script>
</head>
<body>
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top" align="left" width="110" height="186"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
<td width="780" rowspan="2" align="center" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td height="161" valign="top"><img src="images/spacer.gif" alt="" /></td>
</tr>
<tr>
<td valign="top" align="left" class="btn">
<table width="780" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td width="10" valign="top"><img src="images/btn-left.jpg" alt="" width="10" height="49" /></td>
<td align="center" valign="middle">
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="154" align="center" valign="top">Home Page</td>
<td width="180" align="center" valign="top">Our Services</td>
<td width="244" align="center" valign="top">About relyon security</td>
<td width="182" align="center" valign="top"><span class="navg_contact_activated">Contact Us</span></td>
</tr>
</table>
</td>
<td width="10" valign="top" align="right"><img src="images/btn-right.jpg" alt="" width="10" height="49" /></td>
</tr>
<tr>
<td colspan="3" height="1" bgcolor="#FFFFFF"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
<tr>
<td width="10"><img src="images/left-bot.jpg" alt="" width="10" height="42" /></td>
<td class="shadow"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
<td><img src="images/rgh-bot.jpg" alt="" width="10" height="42" /></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td valign="top" align="left" width="110"><img src="images/spacer.gif" alt="" /></td>
</tr>
<tr>
<td valign="top" align="left" width="110" bgcolor="#FFFFFF" height="66"><img src="images/spacer.gif" alt="" /></td>
<td valign="top" align="left" width="110" bgcolor="#FFFFFF"><img src="images/spacer.gif" alt="" /></td>
</tr>
</table>
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center" class="white">
<tr>
<td valign="top" align="left"><table width="780" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top" class="inner_text"><span class="head-blue">Contact Us</span><br /><br />
Email address: relyonsecurity#live.com.au
<br />
Phone: 0422 663 489<br />
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center" class="blue">
<tr>
<td valign="top" align="left"><table width="780" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top">
<form name="contact" method="post" action="includes/contact_mail.php" onsubmit="return fullcheck()">
<table width="90%" border="0" cellpadding="0" cellspacing="3" >
<tr>
<td width="7%"> </td>
<td height="30" colspan="2" align="left" valign="middle"><span class="mandatory">*</span>Required fields</td>
</tr>
<tr>
<td> </td>
<td width="22%" class="form_text"><span class="mandatory">*</span>First Name :</td>
<td width="71%"><input name="fname" type="text" id="fname" size="35" class="inputbox"></td>
</tr>
<tr>
<td> </td>
<td width="22%" class="form_text"><span class="mandatory">*</span>Last Name :</td>
<td width="71%"><input name="lname" type="text" id="lname" size="35" class="inputbox"></td>
</tr>
<tr>
<td> </td>
<td class="form_text"><span class="mandatory">*</span>Email Address :</td>
<td><input name="email" type="text" class="inputbox" id="email" size="35"></td>
</tr>
<tr>
<td width="7%"> </td>
<td class="form_text"><span class="mandatory">*</span>Telephone Number:</td>
<td><input name="tel" type="text" class="inputbox" id="tel" size="35"></td>
</tr>
<tr>
<td> </td>
<td class="form_text"><span class="mandatory">*</span>Please enter your question or comment :</td>
<td><textarea name="que" cols="33" rows="8" id="que" class="inputbox"></textarea></td>
</tr>
<tr>
<td colspan="3" height="5" valign="top"><input name="enter" type="hidden" value="1" /></td>
</tr>
<tr>
<td> </td>
<td class="form_text"> </td>
<td><input type="submit" name="Submit" value="Submit" class="inputbox">
<input type="reset" name="Submit2" value="Reset" class="inputbox"></td>
</tr>
<tr>
<td colspan="3" height="30" valign="top"></td>
</tr>
</table>
</form>
<table width="780" border="0" cellspacing="0" cellpadding="0" align="center" class="footer" height="41">
<tr>
<td valign="top" width="12" height="8"><img src="images/foo-l-top.gif" alt="" width="12" height="8" /></td>
<td><img src="images/spacer.gif" alt="" /></td>
<td align="right" valign="top" width="9" height="8"><img src="images/foo-r-top.gif" alt="" width="9" height="8" /></td>
</tr>
<tr>
<td><img src="images/spacer.gif" alt="" /></td>
<td align="center" valign="middle">©2009 Relyon Security.com All Rights Reserved</td>
<td><img src="images/spacer.gif" alt="" /></td>
</tr>
<tr>
<td valign="bottom" height="8"><img src="images/foo-l-bot.gif" alt="" width="12" height="8" /></td>
<td><img src="images/spacer.gif" alt="" /></td>
<td valign="bottom"><img src="images/foo-r-bot.gif" alt="" width="9" height="8" /></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Second attempt at script?
<?php
error_reporting(E_ALL)
if(isset($_POST['enter']) && $_POST['enter']==1)
{
$_SESSION['email']=$_POST['email'];
$to="name#domains.com";
$subject='Contact Us Details';
$message="<style>
.textstyle{
font-family:Tahoma;
font-size:11px;
color:#156E00;
text-align:left;
margin-left:10px;
text-decoration:none;
}
</style>";
$message.="<table width=400 border=0>
<tr><td class=textstyle>First Name: </td> <td class=textstyle>".$_POST['fname']."</td></tr>
<tr><td class=textstyle>Last Name: </td> <td class=textstyle>".$_POST['lname']."</td></tr>
<tr><td class=textstyle>E-mail: </td> <td class=textstyle>".$_POST['email']."</td></tr>
<tr><td class=textstyle>Phone Number: </td> <td class=textstyle>".$_POST['tel']."</td></tr>
<tr><td class=textstyle>Comments: </td> <td class=textstyle>".$_POST['que']."</td></tr>
</table>";
$mail_from = "From:".$_POST['email'];
$mail_from .="\r\nContent-type: text/html";
mail($to,$subject,$message,$mail_from);
// header("location: ../thankyou.html");
exit();
}
?>
put error_reporting(E_ALL) at the top of the script, remove # from mail() call and comment string with header() and THEN look for errors
When i added <form> to my web page, all my javascript stopped working, and when i put the form at the begining of my table submit wont work, what i am doing wrong. below is my code after testing on other browser it works fine but on Firefox it doesn't
Update: After checking on firefox java error console it appears that Checking Function is defined
Update2: Solved my mistake was <script type="text/jscript"> is wrong thats why on firefox it wasn't working and on the rest it was, it must be <script type="text/javascript">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sabay Afrah.Inc | Contact Us</title>
<script src="js/clear.js" language="javascript" type="text/javascript"></script>
<script src="js/SpryValidationSelect.js" type="text/javascript"></script>
<script type="text/jscript">
function Checking(form){
if(empty(form.fname.value){
alert("do nothing");
}
}
</script>
<style type="text/css">
<!--
body {
background-color: #000;
}
body,td,th {
color: #FFF;
font-size: 14px;
}
.address {
font-family: "Comic Sans MS", cursive;
font-weight: bold;
}
-->
</style>
<link href="theme/style.css" rel="stylesheet" type="text/css" />
<link href="theme/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="enterdb.php" method="post">
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center"> </td>
</tr>
<tr>
<td><table width="1006" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="4"> </td>
<td width="93" align="right"> </td>
<td width="4"> </td>
<td width="374" ><img src="images/logo.png" width="230" height="114" /></td>
<td width="426" align="right" class="address">
10 GlenLake parkway<br />
Suite 130, mailbox # 76<br />
Atlanta, GA 30328<br />
Phone #: + 678-222-3442<br />
Fax #: +678-222-3401<br />
Office hours: M-F 8:30 a.m. to 5:00 p.m.<br />
</td>
<td width="99"> </td>
</tr>
<tr>
<td colspan="5"><table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td class="title"> </td>
</tr>
<tr>
<td width="84"><br /></td>
<td width="516" class="title">Contact Us</td>
</tr>
</table></td>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td>
<table width="883" border="0" align="center" cellpadding="0" cellspacing="0">
<tr class="table">
<td width="27" rowspan="10" bgcolor="#330099" class="textable"> </td>
<td colspan="2" bgcolor="#330099" class="textable"> </td>
<td width="29" rowspan="8" bgcolor="#330099" class="textable"> </td>
<td colspan="3" class="textable"> </td>
</tr>
<tr >
<td width="139" height="31" bgcolor="#330099" class="textable">First Name:</td> <td>
<input id="fname" name="fname" type="text" size="40" /> </td>
<td width="150" class="textable">Last Name:</td>
<td width="265" class="textable"><table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td ><table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td ><input id="lname" name="lname" type="text" size="40" /></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="32" class="textable"> </td>
</tr>
<tr>
<td height="30" class="textable">Subject:</td> <td>
<span id="spryselect1">
<label>
<select name="sub" id="sub">
<option> Choose a Subject</option>
<option> General Question</option>
<option> MemberShip Area</option>
<option> Others</option>
</select>
</label>
<span class="selectRequiredMsg">Please select a Subject.</span></span>
</td>
<td colspan="3" class="textable"> </td>
</tr>
<tr>
<td height="33" class="textable">Company Name:</td> <td> <input id="cname" name="cname" type="text" size="40" /></td>
<td class="textable">Company Address:</td>
<td class="textable"><table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input id="cadd" name="cadd" type="text" size="40" onclick="" /></td>
</tr>
</table></td>
<td class="textable"> </td>
</tr>
<tr>
<td height="31" class="textable">Phone Number:</td> <td><input id="phonen" name="phonen" type="text" size="40" /> </td>
<td colspan="3" rowspan="4" class="textable"> </td>
</tr>
<tr>
<td height="31" class="textable">Fax Number:</td><td> <input id="faxn" name="faxn" type="text" size="40" /></td>
</tr>
<tr>
<td height="32" class="textable">Email Address:</td><td><input id="email" name="email" type="text" size="40" /></td>
</tr>
<tr>
<td colspan="2" class="textable"> </td>
</tr>
<tr>
<td valign="top" class="textable">Additional Information:</td>
<td colspan="5" class="textable"><table width="600" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" align="center">
<textarea id="add" name="add" cols="70" rows="10" /></textarea>
</td>
</tr>
<tr>
<td align="center" class="textable">
<input name="Submit" type="submit" value="Submit" onclick="Checking()"/>
</td>
<td align="center" class="textable">
<input type="reset" value="Clear" />
</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="6" class="textable"> </td>
</tr>
</table></td>
</tr>
</table>
</form>
<script type="text/javascript">
<!--
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
//-->
</script>
</body>
</html>
Your function wants to take in the form element and your submit button doesn't send anything to the function. I'd assume it's not submitting because your function is erroring out and thus stopping the button as if it were returning false. Fix your JavaScript, try using Firebug to help you find these problems.
Try adding an onsubmit to your form tag:
<form action="enterdb.php" method="post" enctype="application/x-www-form-urlencoded" onsubmit="return Checking(this);">
Then remove the onclick event from the submit button.
You need to pass a form object to the Checking function, hence the this. Also it's usually better to place the handler in the form tag as it'll be called when the user submits the form by either clicking the submit button or by pressing enter elsewhere in the form.
Edited per webdestroya.
generally, suggest that you comment out first clear.js and SpryValidationSelect.js, and then try run your code by adding one by one javascript file to clearly defined what is the file that been crashing with your inline code text.
also try to add name for your form and try like this:
function Checking(form){
if(empty(window.myform.fname.value){
alert("do nothing");
}
}
in a way to debug something, its best to try different method by which sometimes you will spot the not easier.
just my thought. gudluck