Hello guys, I am really new to C++ because I am a C#/Java Programmer and I asked myself if it is possible to get a http response after transmitting variables like c# does.
For example, here is my php code which is working fine:
<?php
$host="localhost"; // Der Hostname
$username="user"; // Euer MySQL Username
$password="testpass"; // Euer MySQL Passwort
$db_name="game"; // Der Datenbankname
$tbl_name="user"; // Der Name des Tables
if (!isset($_POST'usernametosend']) or !isset($_POST'passwordtosend'])) die("The username or password is missing!");
// Hier verbinden wir uns mit dem Datenbankserver und selektieren die Datenbank
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("Cannot select Database");
$usernametosend=$_POST'usernametosend'];
$passwordtosend=$_POST'passwordtosend'];
// Dies ist ein Schutz gegen allgemeine SQL Injektionen
if (@get_magic_quotes_gpc())
{
$usernametosend = stripslashes($usernametosend);
$passwordtosend = stripslashes($passwordtosend);
}
$usernametosend = @mysql_real_escape_string($usernametosend);
$passwordtosend = @mysql_real_escape_string($passwordtosend);
$sql="SELECT * FROM $tbl_name WHERE username='$usernametosend' and password='$passwordtosend'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
@mysql_free_result($result);
if($count==1)
{
// Hier wird unsere Session registriert und accepted
$_SESSION'usernametosend'] = $usernametosend;
$_SESSION'passwordtosend'] = $passwordtosend;
echo("accepted");
}
else echo("Wrong username or password"); //Der Login ist fehlgeschlagen
@mysql_close();
?>
So if everything is fine I will get a “accepted” message and if something is wrong “Wrong username or password”.
In C# it works fine with this:
var request = (HttpWebRequest)WebRequest.Create("http://testdomain.net/login.php");
var postData = "usernametosend="+textBox1.Text;
postData += "&passwordtosend=" + textBox2.Text;
var data = Encoding.ASCII.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
MessageBox.Show(responseString);
quiet easy or ?
But how can I do something like this in UE4 ? I wrote all the response posts and didnt got an idea … pls help…
Ty guys