Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] zdefiniowanie zmiennej
Forum PHP.pl > Forum > Przedszkole
-adamus-
Witam wszystkich. Na wstępie mówię, że jestem zielony w PHP. Oto mój problem:
Mam skrypt, który wysyła maile do klientów, którzy robili test. Chciałbym, żeby w przypadku zaliczenia klient dostawał gratulacje, nie zaliczenia - wyrazy współczucia. O ile funkcję if else mogę sobie wyobrazić, to nie bardzo wiem jak zdefiniować zmienną z "gratulacjami" i "przykro nam nie zdałeś" W skrypcie poniżej cały ten tekst jest moim zdaniem w zmiennej $besked, która z kolei jest wwartością f. mail. Czy ktoś mógłby rozjaśnić sprawę? pozdrawiam
A oto skrypt:
<?php
$besked = "Email sent from the Administrator: \n
***************************************************************************
********* Project and access information *******
***************************************************************************
Dear " . utf8_decode($_POST['userID']). "
We regret to inform you that you have exceeded the number of attempts allowed to complete the " . utf8_decode($_POST['projectName']). ".
Administrator will contact you to arrange an alternative training assessment.
In addition, please ensure that you have completed the online user activation form in order to receive access to your trial database.Please note access details will only be issued
once your site has gone Live.
Kind regards,

If you have any questions regarding , please contact us.

Student name: " . utf8_decode($_POST['userID']). "
Project name: " . utf8_decode($_POST['projectName']). "
Contact number: " . $_POST['custom2']. "
Site: ". utf8_decode($_POST['custom1'])."
email address: ". utf8_decode($_POST['recipient'])."
Date completed: " . $_POST['dateCompleted']. "
Time completed: " . $_POST['timeCompleted']. "
Total time spent in course: " . $_POST['timeSpent']. "

***************************************************************************
********* Quizzing Information *******
***************************************************************************

Quiz score in percent: " . $_POST['quiz_user_quiz_percentage']. "
Total Points Scored: " . $_POST['quiz_user_scored_points']. "
Total Points Available: " . $_POST['quiz_total_available_points']. "
Points needed for a pass: " . $_POST['quiz_points_needed_for_a_pass']. "

Number of quiz attempts: " . $_POST['quizAttempts']. "
Total number of quiz questions: " . $_POST['quizQuestions']. "
Total number of correct answers: " . $_POST['quizCorrect']. "
Total number of unanswered questions: " . $_POST['quizUnanswered']."
";

if(isset($_POST['sendCustomVars']) && (strcasecmp($_POST['sendCustomVars'], 'true') == 0)) {
$besked .= "
**************************************************************************
********* Custom Variables *******
***************************************************************************

Custom variable 1: " . utf8_decode($_POST['custom1']). "
Custom variable 2: " . utf8_decode($_POST['custom2']);
}

// Do not edit anything below this line unless you know what you are doing..

// e-mail recipient
$recipient = utf8_decode($_POST['recipient']);

// e-mail subject
$subject = utf8_decode($_POST['subject']);

// e-mail sender
$sender = utf8_decode($_POST['email']);

// send e-mailen
mail($recipient, $subject, $besked, "From: $sender");
?>
Turson
Wstawiaj kod w odpowiednie znaczniki.

Co to za problem.
if($liczbapunktow>od iluś tam) to $wynik = "zdałeś" jeśli nie $wynik="nie zdałeś"
Potem w treści wiadomości wstawiasz $wynik
-adamus-
Dzięki, ok. Tak mniej więcej sobie wyobrażam taką funkcję. Ale czy to nie problem, że cała treść maila jest już w zmiennej $beseked, więc muszę zdefiniować dwie zmienne, i tak jak mówisz mogą to być $wynik1 i $wynik2 ale te zmienne będą już wewnątrz $besked i nie wiem jak tu zadziałać.
Ad
Turson
Najpierw sprawdźczy osoba zdała i zdefiniuj odpowiednie zmienne. Najlepiej jedną na 2 sposoby, inaczej będziesz miał problem, że zmienna nie istnieje.
Potem dodaj do $besked zmienną z informacją o zdaniu/nie zdaniu.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.