Zum Inhalt wechseln

Als Gast hast du nur eingeschränkten Zugriff!


Anmelden 

Benutzerkonto erstellen

Du bist nicht angemeldet und hast somit nur einen sehr eingeschränkten Zugriff auf die Features unserer Community.
Um vollen Zugriff zu erlangen musst du dir einen Account erstellen. Der Vorgang sollte nicht länger als 1 Minute dauern.

  • Antworte auf Themen oder erstelle deine eigenen.
  • Schalte dir alle Downloads mit Highspeed & ohne Wartezeit frei.
  • Erhalte Zugriff auf alle Bereiche und entdecke interessante Inhalte.
  • Tausche dich mich anderen Usern in der Shoutbox oder via PN aus.
 

   

Foto

PHP Tutorial #1 Einfache Textausgabe + Rechnen

- - - - -

  • Bitte melde dich an um zu Antworten
6 Antworten in diesem Thema

#1
Cranky

Cranky

    Hacker

  • Banned
  • PIPPIPPIPPIPPIPPIPPIPPIP
  • Likes
    67
  • 197 Beiträge
  • 18 Bedankt
  • 655869548
  • Android
  • Linux
Hallo Leute!

Ich will für euch eine kleine tutorial reihe über PHP erstellen, ich beginne bei ganz einfachen sachen wie text ausgaben und rechnen und gehe später auf datenbankanfragen usw ein.

Ich werd das alles anhand von source codes die ich selber gemacht hab darstellen. Alle source codes sind kommentiert und die kommentare sind gleichzeitig die beschreibungen der funktionen. Wenn etwas unklar ist, sagt mir einfach bescheid, ich erklärs sofort und/oder editier meinen beitrag. Wird leider alles in englisch sein, aber ihr werdet das schon verstehen, wenn ich es versteh, dann sicher ihr auch.^^.png' class='bbc_emoticon' alt='^^' />

Hier mal der erste Source Code:


<?php
echo "Welcome to the third PHP Tutorial by Cranky.<br><br>";

echo "In this tutorial, I will show you how to code in PHP!<br><br>";


//Echo is just the output command for text. Everything between the two "" after echo, will be displayed.
// These doubleslashes signalize a comment. You can also comment by entering: /* TEXT */

echo (date("j.n.Y")) ;
echo "<br><br><br><br>";

//Set variable names and values. You will see why, later on.

$name = "Cranky";
$rate = 1.255567;
$salary = 140;

//Calculate salary in dollars!

$monday = (4 * $salary);
$tuesday = (2 * $salary);
$wednesday = (3 * $salary);
$thursday = (0 * $salary);
$friday = (6 * $salary);

//Define values for the week, in my case I assign the sum of the days of a week and call it $week.

$week = ($monday + $tuesday + $wednesday + $thursday + $friday);

//Lets do the same with month:

$month = ($week * 4);

//Now we create the exchange rate. I exchange from euro to dollars:

$in_dollar_week = ($week * $rate);
$in_dollar_month = (($week * $rate) * 4);

//Print out the variables you just assigned:

echo "Hello <b>$name</b>,<BR><BR>";
echo "You earned <b>$in_dollar_week</b> $ this week!<br><Br>";
echo "The salary is about <b>$in_dollar_month</b> $ this month.";
?>

  • midn84ever gefällt das

Ich "hacke" keine whatsapp oder facebook accounts aber schreibt mich ruhig an was das betrifft dann hab ich was zu lachen. :D

 

 


#2
Cranky

Cranky

    Hacker

  • Banned
  • PIPPIPPIPPIPPIPPIPPIPPIP
  • Likes
    67
  • 197 Beiträge
  • 18 Bedankt
  • 655869548
  • Android
  • Linux
Hey Leute!

In diesem Tutorial zeige ich euch, wie ihr ein HTML Formular erstellt und dieses dann mit PHP auswertet. Diese Methode funktioniert mit POST. Wer keine Ahnung von HTML hat, sollte jetzt alles wieder auffrischen.^^.png' class='bbc_emoticon' alt='^^' />

HTML:

<HTML>
<HEAD>
<title>Tutorial for Forms in HTML with PHP parsing!</title>
</head>
<body>

<!--assign the post method and the php file for further processing:-->

<form action="processor.php" Method="POST">

<!--Create a Formtype for name which includes several options:-->

Name:<BR>
<select name="name[]">
<option>Cranky</option>
<option>ProGFX</option>
<option>TheExoduss</option>
<option>AliKr96</option>
<option>d2dyno</option>
</select><BR><BR>


<!--students count:-->

Count of Students:<BR>

<input type="text" Name="count"><BR>

<!--get salary per hour:-->

Salary per hour:<BR>

<input type="text" Name="salary"><BR>

<!--Form field with dropdown:-->

Employer:<BR>

<select name="employer[]">
<option>iOSCoderz</option>
<option>Gameguardian</option>
<option>Androidcheats</option>
<option>Marketmilitia</option>
</select>
<BR><P>

<!--assign the calculation button that "POST"s the values to the php file.-->

<Input Type="Submit" name="Go" Value="Calculate">


(c) Cranky
</Form>
</body>
</Html>

Nun zum PHP File. Ich habs hier processor.php genannt, wenn ihr den dateinamen im HTML Code ändert könnt ihr dementsprechend den dateinamen ändern. Das PHP File wird in der nächsten antwort gepostet.

Bearbeitet von Cranky, 16 December 2013 - 01:04 Uhr.

  • midn84ever gefällt das

Ich "hacke" keine whatsapp oder facebook accounts aber schreibt mich ruhig an was das betrifft dann hab ich was zu lachen. :D

 

 


#3
Cranky

Cranky

    Hacker

  • Banned
  • PIPPIPPIPPIPPIPPIPPIPPIP
  • Likes
    67
  • 197 Beiträge
  • 18 Bedankt
  • 655869548
  • Android
  • Linux

<?php

//We assign variables for the posted values from the HTML file:

$name = $_POST['name'];
$count = $_POST['count'];
$salary = $_POST['salary'];
$employer = $_POST['employer'];


//We assign $person for $name:

foreach ($name as $person) {

echo "Hello <B>$person</b>,<br><BR><p>";

}

echo "You have worked <B>$count</b> hours at ";

foreach ($employer as $where_da_fuck) {

echo "<B> $where_da_fuck</b>!<BR><BR>";

}

//calculate outcome -> Salary * Count

$outcome = ($salary * $count);

echo "Your salary in this time was:<BR><BR>";
echo "<b>$outcome</b> Euro";


//© Cranky

?>

  • midn84ever gefällt das

Ich "hacke" keine whatsapp oder facebook accounts aber schreibt mich ruhig an was das betrifft dann hab ich was zu lachen. :D

 

 


#4
Cranky

Cranky

    Hacker

  • Banned
  • PIPPIPPIPPIPPIPPIPPIPPIP
  • Likes
    67
  • 197 Beiträge
  • 18 Bedankt
  • 655869548
  • Android
  • Linux
Hey Leute, hier wieder ein kommentierter Source!

<HTML>
    <Head>
        <Title>Output of the current day</Title>
    </Head>
<BODY>

<?php


//Output of the day:

$name = "Cranky";
$a = date("l");

//Everything between the two {} in this switch will be checked for $a.
//If $a matches, then the output of the text of the day will be shown.

switch ($a) {
    case "Monday":
        $and_now = "Damn its Monday...";
break;
        
    case "Tuesday":
        $and_now = "Unfortunately its tuesday, 3 days left...";
break;
        
    case "Wednesday":
        $and_now = "Half of the week passed by!";
break;
        
    case "Thursday":
        $and_now = "Almost done, now I just need to survive friday!";
break;
        
    case "Friday":
        $and_now = "Tomorrow is weekend!!!";
break;

default:

//it has to be weekend
        
        $and_now = "Finally weekend has come! Today you don??t need to do anything! What a cool day! <img src='http://www.toolbase.bz/board/public/style_emoticons/<#EMO_DIR#>/_0005__D.png' class='bbc_emoticon' alt=':D' />";
}

//Output of the research

echo ("Good morning <b>$name!</b>,<p>");
echo ("$and_now");


?>

</body>
</html>

  • midn84ever gefällt das

Ich "hacke" keine whatsapp oder facebook accounts aber schreibt mich ruhig an was das betrifft dann hab ich was zu lachen. :D

 

 


#5
Cranky

Cranky

    Hacker

  • Banned
  • PIPPIPPIPPIPPIPPIPPIPPIP
  • Likes
    67
  • 197 Beiträge
  • 18 Bedankt
  • 655869548
  • Android
  • Linux
Hey Leute!

Dieses Skript zeigt einen Countdown, es macht nicht wirklich einen Countdown sondern zeigt einfach die Zeilen mit den Zahlen an.


Die For-Schleife beinhaltet immer drei Werte!

Der erste Wert ist der Startwert. Diesen kann man nennen wie man will. Von $i bis hin zu $ilikeittobethis

Der zweiter Wert ist der Stopwert - also wo er aufhören soll zu zaehlen. >= In diesem fall wird die 0 inkludiert.

Der dritte Wert zeigt den Intervall in dem gezaehlt werden soll. $i -- heißt also das 1 vom anfangswert abgezogen wird bis der Wert 0 erreicht wird.

Man könnte es auch so machen: $i = $i - 5 oder wie man halt will.



<?php

for ($i =10; $i>=0; $i --) {
echo "Countdown Nr. $i <br>";
}
?>


  • midn84ever gefällt das

Ich "hacke" keine whatsapp oder facebook accounts aber schreibt mich ruhig an was das betrifft dann hab ich was zu lachen. :D

 

 


#6
Cranky

Cranky

    Hacker

  • Banned
  • PIPPIPPIPPIPPIPPIPPIPPIP
  • Likes
    67
  • 197 Beiträge
  • 18 Bedankt
  • 655869548
  • Android
  • Linux
Dieser Quelltext ist kommentiert und verständlich geschrieben (Sorry fürs englisch, aber ich muss sonst wirklich alles übersetzen)


Dieser Source berechnet die Fakultät einer spezifizierten nummer.


<?php

// set variable values:

$n = 5;
$copy = $n;
$faculty = 1;


//Start a while loop:
//A while loop always starts with a condition
//It looks like this: while ($n > 0) {
//instruction1;
//instruction2;
//}

while ($n > 0) {
    $faculty = ($n + $faculty);
    $n--;
}

//Output of the information:

echo "The faculty of <b>$copy</b> is: ";
echo "<b>$faculty</b>.";

?>

  • midn84ever gefällt das

Ich "hacke" keine whatsapp oder facebook accounts aber schreibt mich ruhig an was das betrifft dann hab ich was zu lachen. :D

 

 


#7
Cranky

Cranky

    Hacker

  • Banned
  • PIPPIPPIPPIPPIPPIPPIPPIP
  • Likes
    67
  • 197 Beiträge
  • 18 Bedankt
  • 655869548
  • Android
  • Linux
Yo Leute!

Wieder ein kommentierter source für euch!


<?php

// Set up sender-data

$sender_name = "Name of the sender";
$sender_mail_adress = "user@Server.exe.com";
$reply_adress = "user@Server.exe.com";

// Set up receiver-data

$receiver_name = "Name of receiver";
$receiver_mail_adress = "receiver@localhostz";

//The message

$message = "Hello, this is a test mail,
the content of this mail, goes
over more than one line.";

//The subject

$subject = "Just a dummy message";

//The mail header

$headers .= "From: ".$sender_name." <".$sender_mail_adress.">\r\n";
$headers .= "Reply-To: ".$sender_name." <$reply_adress>\r\n";

//Fill the mail function with values to send it.

if (mail($receiver_mail_adress, $subject, $message, $headers)) {
echo "The Mail to <b>" . $receiver_name . " </b> has been sent";
} else {
echo "The Mail to <b>" . $receiver_name . " </b> could not be sent!;
}


echo "Copyright © Cranky";
?>


  • midn84ever gefällt das

Ich "hacke" keine whatsapp oder facebook accounts aber schreibt mich ruhig an was das betrifft dann hab ich was zu lachen. :D

 

 




  Thema Forum Themenstarter Statistik Letzter Beitrag

Besucher die dieses Thema lesen:

Mitglieder: , Gäste: , unsichtbare Mitglieder:


This topic has been visited by 14 user(s)


    , bbking, enjoy, Epics, FalkE, Flex.Net, kiwitone, lion., Mugluge, muLTiii, R@zz@R-LightS, speedfreak, xsasuke16x, zxyc
Die besten Hacking Tools zum downloaden : Released, Leaked, Cracked. Größte deutschsprachige Hacker Sammlung.