问题描述:

I've spent all day searching through similar posts, but was unable to solve this issue. I get:

Notice: Undefined index: contact in E:\Joomla!\New XAMPP\xampp\htdocs\makbilit\app.php on line 21

I saw many answers suggesting isset() and empty() functions, but when I add them to the line:

if (!isset($_POST['contact']=="1"))

I get

Parse error: syntax error, unexpected T_IS_EQUAL, expecting ',' or ')' in E:\Joomla!\New XAMPP\xampp\htdocs\makbilit\app.php on line 21

And that error does not seem to lead to a solution....

Would really appreciate anyone taking the time to over the code and helping me out.

I added the whole thing... hope it's OK.

<?php

function SendEmail($subject,$msg,$ip)

// This function emails the admin about different notices

{

$fake = "[email protected]";

$email = "[email protected]";

$subject = "From Website - Contact";

$headers = "MIME-Version: 1.0" . "\r\n";

$headers .= "Content-type:text/html;charset=windows-1255" . "\r\n";

$headers .= 'From:' . $fake . "\r\n";

if (mail($email,$subject,$msg,$headers)) {

?><script> alert('יצירת הקשר נשלחה בהצלחה! נשתדל לחזור אליך בהקדם האפשרי');</script><?

} else {

echo("<p></p>");

}

}

if ($_POST['contact']=="1") {

// Get all the posts

$name = $_POST[name];

$phone = $_POST[phone];

$moed = $_POST[moed];

$msg = $_POST[msg];

$date = date("d.m.Y");

// Build the Message

$msg = "

<center><h2> לקוח מתעניין באמצעות האתר </h2>מקבילית</center>

שם מלא: $name

טלפון: $phone

מייל: $moed

הערות:

$msg

-------------------------------------------

יצירת הקשר התקבלה ב $date

";

// Convert BR's

$msg = nl2br($msg);

// Send the Email

SendEmail($subject,$msg,$ip);

}

?>

<html>

<head>

<META content="text/html; charset=iso-8859-8-i" http-equiv=Content-Type dir="rtl">

<META name="description" content="Makbilit">

<style>A {text-decoration:none} </style>

<style>A:hover {text-decoration:underline} A:hover {font: bold}</style>

<style type="text/css">

.menutitle{

cursor:pointer;

margin-bottom: 5px;

color:"#000";

width:140px;

padding:2px;

text-align:center;

font-weight:bold;

font-size:13px;

font-family:Arial;

/*/*/border:0px solid indianred;/* */

}

a{

text-align:center;

font-weight:bold;

font-family:Arial;

font-size:13px;

color:"#000";

text-decoration:none;

}

.a3{

color:indianred;font-size:13px;

}

body{text-align:center;margin:0 auto;background:#ffffff}

.submenu{

margin-bottom: 0.5em;

}

</style>

<script type="text/javascript">

/***********************************************

* Switch Menu script- by Martial B of http://getElementById.com/

* Modified by Dynamic Drive for format & NS4/IE4 compatibility

* Visit http://www.dynamicdrive.com/ for full source code

***********************************************/

function formCheck(formobj){

// Enter name of mandatory fields

var fieldRequired = Array("phone");

// Enter field description to appear in the dialog box

var fieldDescription = Array("טלפון");

// dialog message

var alertMsg = "עלייך למלא את הפרטים הבאים:\n";

var l_Msg = alertMsg.length;

for (var i = 0; i < fieldRequired.length; i++){

var obj = formobj.elements[fieldRequired[i]];

if (obj){

switch(obj.type){

case "select-one":

if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){

alertMsg += " - " + fieldDescription[i] + "\n";

}

break;

case "select-multiple":

if (obj.selectedIndex == -1){

alertMsg += " - " + fieldDescription[i] + "\n";

}

break;

case "text":

case "textarea":

if (obj.value == "" || obj.value == null){

alertMsg += " - " + fieldDescription[i] + "\n";

}

break;

default:

}

if (obj.type == undefined){

var blnchecked = false;

for (var j = 0; j < obj.length; j++){

if (obj[j].checked){

blnchecked = true;

}

}

if (!blnchecked){

alertMsg += " - " + fieldDescription[i] + "\n";

}

}

}

}

if (alertMsg.length == l_Msg){

return true;

}else{

alert(alertMsg);

return false;

}

}

function showHide(id){

var a = document.getElementById(id).style.display;

document.getElementById(id).style.display = (a == "none") ? "block" : "none";

}

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)

var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change

document.write('<style type="text/css">\n')

document.write('.submenu{display: none;}\n')

document.write('</style>\n')

}

function SwitchMenu(obj){

if(document.getElementById){

var el = document.getElementById(obj);

var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change

if(el.style.display != "block"){ //DynamicDrive.com change

for (var i=0; i<ar.length; i++){

if (ar[i].className=="submenu") //DynamicDrive.com change

ar[i].style.display = "none";

}

el.style.display = "block";

}else{

el.style.display = "none";

}

}

}

function get_cookie(Name) {

var search = Name + "="

var returnvalue = "";

if (document.cookie.length > 0) {

offset = document.cookie.indexOf(search)

if (offset != -1) {

offset += search.length

end = document.cookie.indexOf(";", offset);

if (end == -1) end = document.cookie.length;

returnvalue=unescape(document.cookie.substring(offset, end))

}

}

return returnvalue;

}

function onloadfunction(){

if (persistmenu=="yes"){

var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname

var cookievalue=get_cookie(cookiename)

if (cookievalue!="")

document.getElementById(cookievalue).style.display="block"

}

}

function savemenustate(){

var inc=1, blockid=""

while (document.getElementById("sub"+inc)){

if (document.getElementById("sub"+inc).style.display=="block"){

blockid="sub"+inc

break

}

inc++

}

var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname

var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid

document.cookie=cookiename+"="+cookievalue

}

if (window.addEventListener)

window.addEventListener("load", onloadfunction, false)

else if (window.attachEvent)

window.attachEvent("onload", onloadfunction)

else if (document.getElementById)

window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)

window.onunload=savemenustate

</script>

<style type="text/css">

blink {behavior: url(blink.htc);}

</style>

<public:component>

<public:property name="msec" value="500"/>

<public:method name="blink"/>

<public:method name="pause"/>

<public:attach event="oncontentready" onevent="initBlink()"/>

<public:attach event="onpropertychange" onevent="checkProperty()"/>

</public:component>

<script language="JScript">

// Declare a reference to the interval

var blinkInterval;

function initBlink() {

if (element.style.visibilty == null) element.style.visibility = "visible";

blinkInterval = window.setInterval(element.uniqueID +".blink()", msec);

paused = false;

}

function blink() {

element.style.visibility = (element.style.visibility == "visible") ? "hidden" : "visible";

}

function pause() {

if (paused)

blinkInterval = window.setInterval(element.uniqueID + ".blink()", msec);

else

window.clearInterval(blinkInterval);

paused = !paused;

}

function checkProperty() {

window.status = event.propertyName;

if (event.propertyName == "msec") {

element.pause();

element.pause();

}

}

</script>

</head>

<center>

<body dir="rtl" marginheight=0 topmargin=0>

<table border=0 width=195 height=135 cellpadding=0 cellspacing=0 background="images/contact-side.png">

<tr>

<td align="center" height="33"><font color="#FFFFFF">רוצה לקבל פרטים נוספים?</font></td></tr>

<tr>

<td width=195 valign=top><form method="POST" name="contactform" id="contactform" onSubmit="return formCheck(contactform);">

<input type="hidden" value="1" name="contact" />

<table width=195 border=0 align="center">

<tr>

<td align=right>

<font color="#000">

שם:</font> </td><td>

<INPUT type="text" size=20 name="name"> </td></tr><tr><td>

<font color="#000"> טלפון:</font> </td>

<td>

<INPUT type="text" size=20 name="phone"> </td></tr><tr>

<td>

<font color="#000"> מייל:</font> </td><td>

<INPUT type="text" size=20 name="moed"> </td></tr>

<tr><td colspan="2" align="center">

<input type="submit" name="sendform" value="שלח" /> </td></tr>

</table></FORM>

</td>

</tr>

</table>

<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("UA-5876426-2");

pageTracker._initData();

pageTracker._trackPageview();

</script>

</body>

</html>

网友答案:

You will need to update the following:

$name = $_POST[name];
$phone = $_POST[phone];
$moed = $_POST[moed];
$msg = $_POST[msg];

to

$name = $_POST['name'];
$phone = $_POST['phone'];
$moed = $_POST['moed'];
$msg = $_POST['msg'];

Without the ' or " in the $_POST brackets, PHP assumes that name, phone, moed and msg are CONSTANTS, which most likely do not exist in your POST array.

相关阅读:
Top