0

我整天都在搜索类似的帖子,但无法解决这个问题。我得到: 注意:未定义索引:第 21 行 E:\Joomla!\New XAMPP\xampp\htdocs\makbilit\app.php 中的联系人

我看到很多建议 isset() 和 empty() 函数的答案,但是当我将它们添加到该行时: if (!isset($_POST['contact']=="1")) 我得到 Parse error: syntax error,意外的 T_IS_EQUAL,在第 21 行的 E:\Joomla!\New XAMPP\xampp\htdocs\makbilit\app.php 中期待 ',' 或 ')'

而且该错误似乎并没有导致解决方案....

非常感谢任何人花时间检查代码并帮助我。我添加了整个东西......希望它没问题。

<?php

function SendEmail($subject,$msg,$ip)
// This function emails the admin about different notices
 {
$fake = "site@makbilit.com";
$email = "moshe@makbilit.com";
$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>
4

2 回答 2

0

您将需要更新以下内容:

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

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

如果 $_POST 括号中没有 ' 或 ",PHP 会假定 name、phone、moed 和 msg 是 CONSTANTS,它们很可能不存在于您的 POST 数组中。

于 2012-06-06T16:43:01.157 回答
0

使用此代码:

if(isset($_POST['save'])){ ....... }

于 2017-04-16T17:04:01.657 回答