Я хочу, чтобы всплыло окно с сообщением об ошибке, но оно даже не возникает - PullRequest
0 голосов
/ 02 февраля 2012

я сделал веб-форму, и у меня есть скрипт для работы с этой формой (php), этот скрипт работает нормально, но я также сделал проверку ошибок javascript, теперь, когда я пытаюсь получить некоторый php в этом скрипте, онкаким-то образом ошибки и не проверяет мои ошибки, в javascript,

ниже вы найдете код, который я написал для обработки ошибок, я еще не закончил, но я в настоящее время застрял, так как мне нужноперейти к моей базе данных, чтобы проверить что-то, и там есть ошибки обработчика ошибок javascript.

краткое прохождение: у меня самого есть 0 карм для тестирования этой обработки ошибок.я нажимаю кнопку отправить, и даже если я не заполнил свое имя пользователя, это не показывает ошибку.и приводит меня непосредственно к обработчику php, который действительно находит ошибки.

Do you like the content on our website? Do you want to be a part of it? Want to earn more Karma?<br />
Do you have what it takes to be a content creator? Then sign up here!<br> <br>

<?php 
function getUID()
{
     global $user;
     if ($user->uid) 
     { 
          $userID=$user->uid;
          echo $userID;
     }
     else
    {
          header('Location: http://brokendiamond.org/?q=node/40');
    }
}
function getUN()
{
     global $user;
     if ($user->uid) 
     { 
          $username=$user->name;
     }
echo $username;
}

function getKarma()
{
     include "php-scripts/DBConnection.php";
     $con = getconnection();
     mysql_select_db("brokendi_BD", $con);
     $result = mysql_query("SELECT * FROM userpoints WHERE uid='getUID()'");
     $row = mysql_fetch_array($result);
     $currentkarma = (int)$row['points'];

     echo $currentkarma;
}
?>

<script type="text/javascript">
function validateForm()
{
var name=document.forms["CCF"]["username"].value;
var karma = parseInt(<?php echo json_encode(getKarma()); ?>);
var errors = "";

     if (name==null || name=="")
     {
         errors += "Error: The username field cannot be empty";
     }

    if (karma < 500)
    {
         errors += "Error: Not enough Karma, you need at least 500 karma to submit this form";
    }

    if (errors != "")
    {
         alert(errors);
         return false;
    }
}
</script>

<form name="CCF" action="php-scripts/sendmail.php" method="post" onsubmit="return validateForm()" >
Username: &nbsp;&nbsp;&nbsp;&nbsp
<input type="hidden" name="UserID" value="<?php getUID() ?>">
<input type="text" name="username" value="<?php getUN() ?>" /><br>
E-mail adress: 
<input type="text" name="mail" /><br><br>
What type of 'Content Creator' do you want to become? <br />
<input type="radio" name="CCT" value="Blogger" /> Blogger<br />
<input type="radio" name="CCT" value="Livestreamer" /> Livestreamer<br> <br>
What's your motivation?<br />
<textarea name="motivation" cols="60" rows="6"></textarea><br><br>
Why should we pick you as content creator?<br />
<textarea name="whyshouldwe" cols="60" rows="6"></textarea><br><br>
Do you have some reference material?<br />
<textarea name="reference" cols="60" rows="6"></textarea><br><br>
<h3>Rules to content creation</h3>
<p>You can only submit this once every day, the other versions will not be read, and you will lose Karma for each submit.<br />
When u submit this form, we will examine your account, and we will take a close look to your reference material.<br>
<h4>For Livestreamers Only</h4>
If we think you have what it takes to be a livestreamer ( frequent hours required ) we will examine your stream, and your computer/internet potential.<br />
If that is good enough for the website, you'll become a content creator.<br>
<h4>For Bloggers</h4>
If we think you are blogging material for out website, you will become a content creator, once you are accepted onto the team we will track your progress.<br />
If however you neglect your power or publish inappropriate content, then we will have no choice but to remove you from our team and will revert you to a regular user account.<br><br>
<input name="Send" type="submit" id="art-button-wrapper" value="I donate 500 Karma, and want to become a 'Content Creator'!" />
</form>

Я не могу понять, в чем проблема, или почему это не сработает, потому что я еще недостаточно квалифицирован в javascript.

Заранее спасибо, Джонатан

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...