2012-10-22 4 views
-4

Comment faire pour que je puisse avoir des virgules/et des freins dans mon code php pour la réponse. Quand j'essaye de l'ajouter je reçois ma réponse ne peut pas être ajoutée ou w.e. erreur, et Quand j'appuie sur enter pour passer à la ligne suivante Cela fait juste un espace. Voici mon code:Comment faire pour que je puisse avoir

<?php 

    if($_SESSION['signed_in']) 
    { echo ' 
    <div style="clear: both;">&nbsp;</div> 

    <div class="header"> 
     <h3>Post Reply</h3> 
    </div> 
    <div class="container_oro2"> 

    <div class="cpadding"> 
    <input type="button" class="bbbutton light" title="[color=][/color]" value="Color" /> 
    <input type="button" class="bbbutton light" title="[size=11px][/size]" value="Size" /> 
    <input type="button" class="bbbutton light" title="[b][/b]" value="Bold" /> 
    <input type="button" class="bbbutton light" title="[i][/i]" value="Italic" /> 
    <input type="button" class="bbbutton light" title="[u][/u]" value="Underline" /> 
    <input type="button" class="bbbutton light" title="[img][/img]" value="Image" /> 
    <input type="button" class="bbbutton light" title="[url=http://][/url]" value="URL" /> 
    <input type="button" class="bbbutton light" title="[center][/center]" value="Center" /> 
    <input type="button" class="bbbutton light" title="[quote=][/quote]" value="Quote" /> 
    <input type="button" class="bbbutton light" title="[spoiler][/spoiler]" value="Spoiler" /> 
    <input type="button" class="bbbutton light" title="[youtube]http://www.youtube.com/watch?v=[/youtube]" value="YouTube Video" /> 
    </div> 

    <br/> <form action="" method="post"> 
     <div class="center"> 
      <textarea id="form" name="reply-content" cols="70" rows="8"> </textarea> 
      <br/><input type="submit" name="add_submit" value="Submit Post" />  </div> 
    </form> 


</div>'; 
    } 
    else 
    { 
       echo '<div style="clear: both;">&nbsp;</div> 

     <div class="header"> 
     <h3>Post Reply</h3> 
    </div> 
    <div class="container_oro2"> 


    <div class="center"><B>You must <a href="/index.php?area=login">Login</a> or <a href="/index.php?area=register">create an account</a> to 

    post.</B></div> 


    </div> 


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

    echo ''; 
    } 
    else 
    { 

    if(!$_SESSION['signed_in']) 
    { 
     echo 'You must be signed in to post a reply.'; 
    } 
    else 
    { 

     $sql = "INSERT INTO 
        posts(post_content, 
          post_date, 
          post_topic, 
          post_by) 
       VALUES ('" . $_POST['reply-content'] . "', 
         NOW(), 
         " . mysql_real_escape_string($_GET['id']) . ", 
         " . $_SESSION['user_id'] . ")"; 

     $result = mysql_query($sql); 

     if(!$result) 
     { 
      echo 'Your reply has not been saved, please try again later.'; 
     } 
     else 
     { $Max_id = $rows['reply']+1;$id=($_GET['id']); 
    header('Location: /index.php?area=topic&id=' . htmlentities($_GET['id']) . '') ; 
      echo 'Your reply has been saved, check out <a href="">the topic</a>.'; 
    $sql2 = "UPDATE $topics SET reply='$Max_id' WHERE id='$id'"; $result2=mysql_query($sql2);} 
    } 
    } 
    ?> 
+0

S'il vous plaît lire: http://stackoverflow.com/questions/how-to-ask –

+0

Pouvez-vous s'il vous plaît expliquer votre problème un peu plus? Il suffit de coller le code et de dire "réparer ceci" n'est pas très bien reçu ici. –

Répondre

2

Je ne suis pas sûr de ce que vous essayez de faire, mais je ne serais pas tout ce que l'écho HTML en utilisant PHP - plutôt en utilisant les balises fermées:

<?php if($_SESSION['signed_in']) { ?> 

HTML 

<? } ?> 
0

Vous ne voulez probablement pas utiliser tout ce code dans le même fichier. Cependant, en réponse à votre question, vous pouvez supprimer les déclarations d'écho et simplement utiliser des blocs de HTML. par exemple:

<?php if($_SESSION['signed_in']){ ?> 
    <div style="clear: both;">&nbsp;</div> 
    <div class="header"> 
     <h3>Post Reply</h3> 
    </div> 
    <div class="container_oro2"> 
     <div class="cpadding"> 
      <input type="button" class="bbbutton light" title="[color=][/color]" value="Color" /> 
      <input type="button" class="bbbutton light" title="[size=11px][/size]" value="Size" /> 
      <input type="button" class="bbbutton light" title="[b][/b]" value="Bold" /> 
      <input type="button" class="bbbutton light" title="[i][/i]" value="Italic" /> 
      <input type="button" class="bbbutton light" title="[u][/u]" value="Underline" /> 
      <input type="button" class="bbbutton light" title="[img][/img]" value="Image" /> 
      <input type="button" class="bbbutton light" title="[url=http://][/url]" value="URL" /> 
      <input type="button" class="bbbutton light" title="[center][/center]" value="Center" /> 
      <input type="button" class="bbbutton light" title="[quote=][/quote]" value="Quote" /> 
      <input type="button" class="bbbutton light" title="[spoiler][/spoiler]" value="Spoiler" /> 
      <input type="button" class="bbbutton light" title="[youtube]http://www.youtube.com/watch?v=[/youtube]" value="YouTube Video" /> 
     </div> 

     <br/> 
     <form action="" method="post"> 
      <div class="center"> 
       <textarea id="form" name="reply-content" cols="70" rows="8"> </textarea> 
       <br/><input type="submit" name="add_submit" value="Submit Post" /> 
      </div> 
     </form> 
    </div> 
<?php } else { ?> 
    <div style="clear: both;">&nbsp;</div> 
    <div class="header"> 
     <h3>Post Reply</h3> 
    </div> 
    <div class="container_oro2"> 
     <div class="center"><B>You must <a href="/index.php?area=login">Login</a> or <a href="/index.php?area=register">create an account</a> to post.</B></div> 
    </div> 
<?php } 

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

<?php } else { 
    if(!$_SESSION['signed_in']){ 
     echo 'You must be signed in to post a reply.'; 
    }else{ 
     $sql = "INSERT INTO 
        posts(post_content, 
          post_date, 
          post_topic, 
          post_by) 
       VALUES ('{$_POST['reply-content']}', 
         NOW(), 
         " . mysql_real_escape_string($_GET['id']) . ", 
         '{$_SESSION['user_id']}')"; 

     $result = mysql_query($sql); 

     if(!$result) { 
      echo 'Your reply has not been saved, please try again later.'; 
     } else { 
      $Max_id = $rows['reply']+1;$id=($_GET['id']); 

      echo 'Your reply has been saved, check out <a href="">the topic</a>.'; 
      $sql2 = "UPDATE $topics SET reply='$Max_id' WHERE id='$id'"; $result2=mysql_query($sql2);} 
      header('Location: /index.php?area=topic&id=' . htmlentities($_GET['id'])) ; 
     } 
    } 
?> 
Questions connexes