Jump to content

process problems


doddsey_65

Recommended Posts

i have a form for which the data is sent to a process page via jquery like so:

 

jQuery.post('<?php echo $this->site_root; ?>/modules/new_post_process.php',{ 
        message:jQuery("#message_contents").val() } ,function(data)
        {

etc...

 

new_post_process checks the contents of message like so:

 

if (empty($message) && empty($error))
    {
        $is_error = true;
        $error = 'Please Enter A Message';
    }

 

the problem is that it always throws this message even when the textarea isnt empty. however after the error has appeared if i submit again it goes through fine. I suppressed the error and tried and the database gets populated with an empty value which means it is indeed empty. so why does it work on the second time around? I am using CKEditor for the textarea. everything else gets submitted normally but this textarea. heres the full code:

 

 

the textarea:

 

<textarea cols="80" rows="10" id="message_contents"></textarea>

jQuery("#new_post_form").submit(function()
    {
jQuery.post('<?php echo $this->site_root; ?>/modules/new_post_process.php',{ 
        user_name:jQuery("#user_name").val(),
        redirect_url:jQuery("#redirect_url").val(),
        subject:jQuery("#subject_field").val(),
        forum_id:jQuery("#fid").val(),
        topic_id:jQuery("#tid").val(),
        method:jQuery("#method").val(),
        message:jQuery("#message_contents").val() } ,function(data)
        { 
            if (data == 1)
                {
                    jQuery("#process_info").removeClass().addClass("subject_okay").html("<img src=\"<?php echo $this->template_path; ?>icons/small_tick.png\" alt=\"icon\" />Redirecting...").fadeIn("slow");
                    var URL = jQuery("#redirect_url").val();
                    document.location = URL;
                }
                else
                { 
                    jQuery("#reply_btn").css("visibility", "visible");
                    jQuery("#draft_btn").css("visibility", "visible");
                    jQuery("#process_info").removeClass().addClass("subject_error").html('<img src="<?php echo $this->template_path; ?>icons/small_error.png" alt="icon" /> ' + data).fadeIn("slow");
                }
        });

 

and the process page:

 

if (isset($_POST['subject']))
{
$message = $_POST['message'];

if (empty($message) && empty($error))
    {
        $is_error = true;
        $error = 'Please Enter A Message';
    }
if (empty($error) && $is_error == false)
    {
        $query = $link->prepare("INSERT INTO 
                ".TBL_PREFIX."posts
                (p_fid, p_tid, p_poster, p_name,
                p_content, p_time_posted)
                VALUES
                ('$forum_id', '$topic_id', '$user_name',
                '$subject', '$message', '".$config['time_now']."')
                ") or die(print_link_error());

echo "1";
    }
    else
    {
        echo $error.'-'.$message;
    }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.