Gebruik session_start ? Als je met de userid session dingen wil doen is het misschien handig om session_start(); te gebruiken ?
[PHP] SMSapi
Sjoerd schreef:Wat werkt er niet? En wat zie je in de urlbalk op het begin?Aan " t werkt nog steeds niet." heb ik niet zo veel..
Url is bijvoorbeeld urlblablabla.nl/hoi.php?userid=
Wat staat er achter de = ?
Achter de = komt je ID te staan. Die haalt ie gewoon netjes op, de connectie is er dus met de database.
Maar na je betaling ben je gewoon geen premium?
Zegt hij dan wel dat je betaald heeft, en geeft hij verder geen error?
Misschien controleert je systeem dan niet of je premium bent met IF(premium = 1) o.i.d?
Misschien controleert je systeem dan niet of je premium bent met IF(premium = 1) o.i.d?
Hij zegt gewoon dat je betaalt hebt (ik gebruik de testmodus
) en hij geeft verder geen error.
Geen idee.. dat is ook niet nodig want niemand is premium? Of is dat wel nodig?
) en hij geeft verder geen error.Geen idee.. dat is ook niet nodig want niemand is premium? Of is dat wel nodig?
Maak van regel 58 eens:
echo <form action="example.php" method="post">Code: <input type="text" name="code" /><input type="hidden" id="userid" name="userid" value=".$user_fetch[id]." /><br /><input type="submit" value="Ok" /></form>; Gamedealer schreef:Nog steeds geen resultaat, niks veranderd.Maak van regel 58 eens:echo <form action="example.php" method="post">Code: <input type="text" name="code" /><input type="hidden" id="userid" name="userid" value=".$user_fetch[id]." /><br /><input type="submit" value="Ok" /></form>;
Hij zegt gewoon dat je betaalt hebt (ik gebruik de testmodus ) en hij geeft verder geen error, maar je wordt geen premium... Azdinnn schreef:heb je al naar mijn code gekeken in dit topic? Het echoén van de query in $sql is ook handig bij het debuggen.Wat werkt er niet? En wat zie je in de urlbalk op het begin?Eerdere citaten tonen
Sjoerd schreef:Aan " t werkt nog steeds niet." heb ik niet zo veel..
Url is bijvoorbeeld urlblablabla.nl/hoi.php?userid=
Wat staat er achter de = ?
Achter de = komt je ID te staan. Die haalt ie gewoon netjes op, de connectie is er dus met de database.
Maar na je betaling ben je gewoon geen premium?
Staat in de database premium ook niet op 1?
$user_query = mysql_query("SELECT username FROM leden WHERE id = ".$user_id." LIMIT 1") or die(mysql_error());
$user_fetch = mysql_fetch_assoc($user_query); Je vraagt username op en je probeert id uit te voeren.
Maak dus van regel 51 dit:
$user_query = mysql_query("SELECT id, username FROM leden WHERE id = ".$user_id." LIMIT 1") or die(mysql_error()); Sjoerd schreef:Staat in de database premium ook niet op 1?
Nop, hij wil hem maar niet updaten..
Gamedealer schreef:Je vraagt username op en je probeert id uit te voeren.$user_query = mysql_query("SELECT username FROM leden WHERE id = ".$user_id." LIMIT 1") or die(mysql_error()); $user_fetch = mysql_fetch_assoc($user_query);
Maak dus van regel 51 dit:
$user_query = mysql_query("SELECT id, username FROM leden WHERE id = ".$user_id." LIMIT 1") or die(mysql_error()); Geprobeerd maar nog steeds niks:
Quote:
Hij zegt gewoon dat je betaalt hebt (ik gebruik de testmodus ) en hij geeft verder geen error, maar je wordt geen premium...
Echo je query-string, dan weet je wat er aan MySQL gevoerd wordt.
Aarclay schreef:Geen idee hoe dat moet dus vertel..?Echo je query-string, dan weet je wat er aan MySQL gevoerd wordt.
gewoon zo?:
zie regel 95
zie regel 95
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]/*******
* Voorbeeldscript voor de werking met de SMS API voor one2xs
* Meer informatie: http://www.one2xs.com/smsapiinfo
* Versie 1.1.0
* Copyright one2apps 2009 - 2012
* Datum 12 oktober 2009
* Laatste wijziging: 16 februari 2012
* Alle rechten voorbehouden.
* Gebruik op eigen risico.
* Misbruik wordt bestraft.
***
* Dit is een voorbeeldscript; je bent vrij om je eigen draai aan het systeem te geven, op voorwaarde dat je je aan de regels houdt.
* Succes ermee.
* LET OP!!! WERKT ENKEL VOOR NEDERLANDSE BEZOEKERS; MENSEN UIT BELGIÀ‹ KUNNEN DUS MET DEZE API NIET SMSEN ZODAT JIJ ER PUNTEN VOOR KRIJGT.
**/[/COLOR]
[COLOR= #0000BB]$testmodus[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$db_host[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]localhost[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$db_username[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]db[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$db_password[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]password[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$db_tabel[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]database[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Azdinnn[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// gebruikersnaam op one2xs voor wie gebeld moet worden[/COLOR]
[COLOR= #0000BB]$bedrag[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]2.20[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// het bedrag; je kunt kiezen uit 2.20 of 4.40[/COLOR]
[URL="http://www.php.net/error_reporting"]error_reporting[/URL][COLOR= #007700]([/COLOR]E_ALL[COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/include_once"]include_once[/URL] [COLOR= #DD0000]api.cls.php[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$db_host[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$db_username[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$db_password[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$db_tabel[/COLOR][COLOR= #007700]);
function[/COLOR] format[COLOR= #007700]([/COLOR][COLOR= #0000BB]$bedrag[/COLOR][COLOR= #007700])[/COLOR] [COLOR= #FF8000]// functie om de bedragen (euros) netjes weer te geven (punten en kommas op de goede plek)[/COLOR]
[COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/number_format"]number_format[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bedrag[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000],[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000].[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]code[/COLOR][COLOR= #007700]]))[/COLOR] [COLOR= #FF8000]// betaling voorbereiden als er geen telnr en code is opgegeven[/COLOR]
[COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$user_id[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]userid[/COLOR][COLOR= #007700]];[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/ctype_digit"]ctype_digit[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]userid[/COLOR][COLOR= #007700]]))
{[/COLOR]
[COLOR= #0000BB]$user_query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT id,username FROM leden WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$user_id[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" LIMIT 1"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$user_query[/COLOR][COLOR= #007700]))
{[/COLOR]
[COLOR= #0000BB]$api[/COLOR] [COLOR= #007700]= new[/COLOR] api[COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]init[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$bedrag[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]// api instantie maken voor een betaling van EUR 4,40[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$api[/COLOR][COLOR= #007700]->[/COLOR]doTransaction[COLOR= #007700]() ===[/COLOR] TRUE[COLOR= #007700])
{[/COLOR]
[COLOR= #0000BB]$content[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$api[/COLOR][COLOR= #007700]->[/COLOR]getMessages[COLOR= #007700]();[/COLOR] [COLOR= #FF8000]// berichten ophalen[/COLOR]
[COLOR= #0000BB]$user_fetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$user_query[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Hallo <strong>[/COLOR][COLOR= #007700].[/COLOR]htmlspecialchars[COLOR= #007700]([/COLOR][COLOR= #0000BB]$user_fetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]</strong>!<br/>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]SMS <strong>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$content[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]code[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</strong> naar <strong>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$content[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]telnr[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</strong> en vul de code die je krijgt hieronder in.<br />[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit kost je € [/COLOR][COLOR= #007700].[/COLOR]format[COLOR= #007700]([/COLOR][COLOR= #0000BB]$content[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]per_eenheid[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000] per [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$content[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]per[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] (totaal dus € [/COLOR][COLOR= #007700].[/COLOR]format[COLOR= #007700]([/COLOR][COLOR= #0000BB]$content[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000], want [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$content[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]extra[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]).<br />[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<form action="example.php" method="post">Code: <input type="text" name="code" /><input type="hidden" name="userid" value="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$user_fetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" /><br /><input type="submit" value="Ok" /></form>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]// Je bent VERPLICHT om het servicenummer, de prijs per eenheid (bijvoorbeel 1,10 euro per SMS) en het totaal aantal SMSjes weer te geven
// Zie http://www.one2xs.com/smsapiinfo voor meer informatie.[/COLOR]
[COLOR= #007700]}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]API fout.[/COLOR][COLOR= #007700];
}
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Geen bestaand userid.[/COLOR][COLOR= #007700];
}
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Geen geldig userid.[/COLOR][COLOR= #007700];
}
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$api[/COLOR] [COLOR= #007700]= new[/COLOR] api[COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]volt[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$bedrag[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]// verwerking van de betaling[/COLOR]
[COLOR= #0000BB]$api[/COLOR][COLOR= #007700]->[/COLOR]addParam[COLOR= #007700]([/COLOR][COLOR= #DD0000]code[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]code[/COLOR][COLOR= #007700]]);[/COLOR] [COLOR= #FF8000]// SMS code meezenden[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$api[/COLOR][COLOR= #007700]->[/COLOR]doTransaction[COLOR= #007700]() ===[/COLOR] TRUE[COLOR= #007700])
{[/COLOR]
[COLOR= #0000BB]$ret[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$api[/COLOR][COLOR= #007700]->[/COLOR]getMessages[COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ret[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]betaald[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]1[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$testmodus[/COLOR] [COLOR= #007700]==[/COLOR] true[COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]userid[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/ctype_digit"]ctype_digit[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]userid[/COLOR][COLOR= #007700]]))
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"UPDATE leden SET premium = 1 WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]userid[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE leden SET premium = 1 WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]userid[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt betaald![/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt betaald, maar geen premium ontvangen. Ga niet aan formuliertjes klooien.[/COLOR][COLOR= #007700];
}
}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ret[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]betaald[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt niet betaald.[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ret[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]betaald[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Deze code is al gebruikt in de testmodus.[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Onbekende fout. Neem contact op met de beheerders voor meer informatie.[/COLOR][COLOR= #007700];
}
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]API fout.[/COLOR][COLOR= #007700];
}
}[/COLOR]
?>Sjoerd, toppie gozer, het werkt nu 


toevoeging op 3 mei 2012, 14:51:25:
Bedankt!



toevoeging op 3 mei 2012, 14:51:25:
Bedankt!
Zullen we even die lijnen aanpassen naar dit?
Gelieve niet het hoofd in het zand te steken als ik met advies kom.
[COLOR= #0000BB]<?php[/COLOR] [COLOR= #FF8000]// kleurtjes[/COLOR]
[COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"UPDATE leden SET premium = 1 WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]userid[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt betaald![/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"FOUT: "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]().[/COLOR][COLOR= #DD0000]"<br />"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700];[/COLOR]
?> Gelieve niet het hoofd in het zand te steken als ik met advies kom.
" heb ik niet zo veel..