Location: PHPKode > scripts > WH Social > wh_social/create.php
<?php require('framework/session.php'); ?>
<?php require('framework/ready.php'); ?>
<?php require('style/layout/header.php'); ?>

<div id="content_wrapper">
    <div class="content">

    <?php

        echo '<div class="content_left">
        <div id="breadcrumb">
            <ul class="crumbs">
                <li class="first"><a href="index.php" style="z-index:9;"><span></span>' . $lang['index'] . '</a></li>
                <li><a href="discussions.php" style="z-index:8;">' . $lang['discussions'] . '</a></li>
                <li><a href="create.php" style="z-index:7;">' . $lang['create_discussion'] . '</a></li>
            </ul>
        </div>
        </div>

        <div class="content_right">';

            include('modules/search.inc.php');
        echo '</div>

        <div class="clear_long"></div>';

        $ret = 1;

        echo '<div class="main_menu">';

            $ret = include 'framework/templates/'.$main_content['menu'];
        echo '<div id="line"></div>';

            $ret = include 'framework/templates/'.$main_content['infos'];
        echo '</div>';

        echo '<div class="main_content">';

        echo '<h1 class="p_space">' . $lang['discussions'] . '</h1>';

        if($_SERVER['REQUEST_METHOD'] != 'POST') {

        include_once('framework/functions/captcha.php');

        echo '<form method="post" name="create" action="">
        <p><input type="text" name="subject" id="subject" class="textfields" required size="40" maxlength="40"> ' . $lang['title'] . '</p>
        <textarea cols="45" rows="8" name="content" id="content" class="textareas"></textarea>
        <p><small>Captcha *</small><br>
        ' . $lang['the_sum_of'] . ' ' . $random1 . ' + ' . $code . ' = <input size="5" name="zip" id="Spamschutz" type="text" class="captchas" required><input type="hidden" name="zip2" value=' . $rand_result . '></p>
        <p><input type="submit" name="submit" value="' . $lang['create_discussion'] . '" alt="' . $lang['create_discussion'] . '" class="buttons"></p>
        <input type="hidden" name="submitted" value="TRUE">
        </form>';

			}else{

			$query  = "BEGIN WORK;";
			$result = mysql_query($query) OR die(mysql_error());

		if(!$result) {

		echo '' . $lang['an_error_occurred'] . '' . mysql_error();

            }else{

			if(sha1($_POST["zip"]) != $_POST["zip2"]) {

			echo '<p>' . $lang['captcha_invalid'] . ' - <a href="javascript:history.back();">' . $lang['back'] . '</a></p>';

		}else{

		$errors = array();

		if(isset($_POST['subject'])) {
		if(trim($_POST['subject']) == "") {
		$errors[] = $lang['enter_a_title'];
		}

			}else{
			$errors[] = $lang['enter_a_title'];
			}

		if(isset($_POST['content'])) {
		if(trim($_POST['content']) == "") {
		$errors[] = $lang['enter_a_text'];
		}

			}else{
			$errors[] = $lang['enter_a_text'];
			}

		if(!empty($errors)) {

        echo '<p>' . $lang['not_filled_in_all_fields'] . ' - <a href="javascript:history.back();">' . $lang['back'] . '</a></p>';
		echo '<ul>';

		foreach($errors as $key => $value) {
		echo '<li>&#8226; ' . $value . '</li>';
		}
		echo '</ul>';

			}else{

			$sql = "INSERT INTO
        				topics(subject, date, author)
        			VALUES ('" . mysql_real_escape_string($_POST["subject"]) . "',
        				NOW(),
        				'" . (int)$_SESSION['id'] . "'
        				)";

			$result = mysql_query($sql) OR die(mysql_error());

		if(!$result) {

		echo '<p class="false">' . $lang['an_error_occurred'] . '</p>';

        $sql = "ROLLBACK;";
		$result = mysql_query($sql) OR die(mysql_error());

			}else{

			if(sha1($_POST["zip"]) != $_POST["zip2"]) {

				echo '<p>' . $lang['captcha_invalid'] . ' - <a href="javascript:history.back();">' . $lang['back'] . '</a></p>';

		}else{

		$belong = mysql_insert_id();

		$sql = "INSERT INTO
					discussions(content, topic, date, author)
				VALUES ('" . mysql_real_escape_string($_POST['content']) . "',
					'" . $belong . "',
					NOW(),
					'" . (int)$_SESSION['id'] . "'
					)";

		$result = mysql_query($sql) OR die(mysql_error());

		if(!$result) {

		echo '<p class="false">' . $lang['could_not_create'] . '</p>';

		$sql = "ROLLBACK;";
		$result = mysql_query($sql) OR die(mysql_error());

			}else{

			$sql = "COMMIT;";
			$result = mysql_query($sql) OR die(mysql_error());

			$autoforward = 3;

			echo '<p class="success">' . $lang['success_create'] . '!</p>
			<meta http-equiv="refresh" content="' . $autoforward . '; URL=read_discussion.php?id='. $belong . '">';
			}
        }

        }}}}}

	?>

<?php require('style/layout/footer.php'); ?>
Return current item: WH Social